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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2009
    Posts
    193
    Thanks
    0
    Thanked 20 Times in 20 Posts

    Mod_Rewrite issue picking up wrong file

    I am new with mod_rewrite and have come across an issue. I am building a site where the site goes through one file index.php and index.php handles the right code it needs to pick up.

    I set up my links to look like example.com/user and that is being rewritten as example.com?section=user.


    The problem that I am having is I have two files in my root directory and when I go to example.com/search it loads up an old file called search.php. I only have index.php and search.php in my root directory. If I use example.com?section=search then it works fine. If I do example.com/user like my first example then it works fine. I don't know why it is picking up search.php and I don't want it to pick up search.php.

    My current mod_rewrite rules look like

    Code:
    RewriteRule ^([A-Za-z0-9]+)/?$ index.php?s=$1 [NC,L]

  • #2
    New Coder
    Join Date
    Dec 2008
    Location
    india
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    Can you post the code of index.php and search.php, so that some one might analyse and give you better response if they find time.

    As well as post all the redirection code in your .htaccess file

  • #3
    Regular Coder
    Join Date
    Jan 2009
    Posts
    193
    Thanks
    0
    Thanked 20 Times in 20 Posts
    Quote Originally Posted by divinequran View Post
    Hi,

    Can you post the code of index.php and search.php, so that some one might analyse and give you better response if they find time.

    As well as post all the redirection code in your .htaccess file
    Search.php just has an exit statement at the top because it isn't in use and index.php is just a switch statement that figures out which file needs to be include. I know it is nothing to do with the php code.

    My .htaccess has only that one line for redirection.

    The problem seems to be the server things that www.example.com/search is the same as www.example.com/search.php. The rewrite isn't even picking it up. When I do a print_r on my $_GET data the array is empty. So I don't know why the rewrite rule isn't picking it up.


  •  

    Posting Permissions

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