Welcome to WebmasterWorld Guest from 54.159.214.27

Forum Moderators: Ocean10000 & incrediBILL & phranque

Invoking .php script rather than following redirect

.php apache redirect rewriterule

   
9:01 am on Sep 16, 2010 (gmt 0)

5+ Year Member



Hi All,

Having a problem at the moment running a website locally (under Ubuntu Linux 10.04) which is working fine on the live website (under CentOS).

The following redirect in the .htaccess file should redirect a call to 'www.domain.com/products/promotional_desk_plants.html' to the searchresults.php script, passing it the product as a query string:

RewriteRule ^products/promotional_(.*)\.html$ /searchresults.php?ln=$1 [NC,L]


This works fine on the live website, but when running locally on the Ubuntu box it is invoking the products.php script, which exists in the root directory, rather than following the redirect.

As a test I created a script in root directory called ‘andy.php’ and if I type in ‘http://domain.local/andy/xxrubbishxx’ it calls the ‘andy.php’ script, rather than giving a ‘page not found’.

Any help on this greatly appreciated!

Andy
11:44 pm on Sep 17, 2010 (gmt 0)

5+ Year Member



Hi Andy,

Do you have mod_speling activated in your local apache install?

Also, put a

AcceptPathInfo off

at the beginning of your .htaccess file (in the local Ubuntu box).

If it's not done by some other rules you have in your .htaccess as well I suspect a AcceptPathInfo on handed over to mod_speling, the last one searching for for similar named files (products->products.php) and handing it over.
4:53 pm on Sep 18, 2010 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



That code is an internal URL-path-to-filepath rewrite, not an external client URL-to-URL redirect. Don't confuse the two, as it makes understanding and using mod_rewrite much more difficult.

As well as mod_speling, you could be getting interference from mod_negotiation. If not required by your site, disable content negotiation by adding "-MultiViews" to the Options directive likely already at the top of your .htaccess file. For example:
Options +FollowSymLinks -Indexes -MultiViews 

is a "typical" setting when using mod_rewrite.

Jim
7:39 pm on Sep 21, 2010 (gmt 0)

5+ Year Member



Spiekerooger & Jim,

Many thanks for your help on this. I'll try these options out and let you know.

Andy
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month