Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question .htaccess mod_rewrite issues

    Hi guys im new here so please be nice

    Ok im having some problems with understanding how htaccess files work with php. Ive written a site in php which uses dynamic content so I want to rewrite the querystrings.

    As it stands within the php code ive written it so the URLs are outputted with the format:
    http://www.mysite.com/view.php?tn=all&order=1&page=1

    And im after something like:
    http://www.mysite.com/view/all/1/1

    Do I need to modify the format I output these URLs within the php....or does the htaccess file do everything?

    As it stands ive got:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule view/(.*)/(.*)/(.*)/$ view.php?tn=$1&order=$2&page=$3

    Can anyone help me out with this please? Ive been trying to get this working a while and arent sure what im doing wrong. Everything I try either doesnt work or gets a server error.

    Thanks in advance.

  • #2
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    try:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule view/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/$ /view.php?$1=$2&$3=$4&$5=$6

    will output

    http://www.mysite.com/view/tn/all/order/1/page/1/

    Got this from

    http://www.webmaster-toolkit.com/mod...enerator.shtml

    but you can try editing it.

    If you want it the way you stated I think you can use this:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule view/(.*)/(.*)/(.*)/$ /view.php?tn=$1&order=$2&page=$3

    which means your links will be:

    http://www.mysite.com/view/all/1/1

    i think

  • #3
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help but I think it may have something to do with my php opposed to the htaccess....obviously im a newbie to this so stop me if im wrong.

    Say for example I create a hyperlink and echo out the querystring like below, will the htaccess rewriting of querystrings work?

    <a href="<?php echo "view_values.php?tn=all&amp;order=$order&amp;page=1"; ?>">All</a>

    I cant work out where Im going wrong at all. Any help appreciated greatly....its driving me crazy. Im told the server has been configured for htaccess and mod_rewrite so dont think the problem lies there.

    Thanks.

  • #4
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    ah sorry i didnt read your post properly, no im pretty sure that you hae to create the links yourself in php. Before you mess everything up id suggest you make it a chooseable option via mysql si you can do:

    $usemodrewrite = "yes";
    if ($usemodrewrite == "yes") {

    $link = "http://www.mysite.com/view/tn/all/order/1/page/1/";

    } else {

    $link = "http://www.mysite.com/view.php?tn=all&order=1&page=1";

    }

  • #5
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is just too much fun. Ive now altered the links into a format like:
    http://www.mysite.com/view_value/all/1/1

    Now Im getting the following 404 error:

    The requested URL /view_value/all/1/1 was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

    My htaccess file looks like:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule view_value/(.*)/(.*)/(.*)/$ /view_value.php?tn=$1&order=$2&page=$3

    Any ideas where im going wrong at all?

    Thanks

  • #6
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help Anthony Ive solved it now.


  • #7
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    can you post what it was ?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •