...

View Full Version : Mod_Rewrite issue picking up wrong file



skywalker2208
11-09-2010, 09:13 PM
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



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

divinequran
11-11-2010, 05:34 AM
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

skywalker2208
11-11-2010, 03:42 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum