homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Invoking .php script rather than following redirect
.php apache redirect rewriterule

5+ Year Member

Msg#: 4202638 posted 9:01 am on Sep 16, 2010 (gmt 0)

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!




5+ Year Member

Msg#: 4202638 posted 11:44 pm on Sep 17, 2010 (gmt 0)

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.


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

Msg#: 4202638 posted 4:53 pm on Sep 18, 2010 (gmt 0)

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.



5+ Year Member

Msg#: 4202638 posted 7:39 pm on Sep 21, 2010 (gmt 0)

Spiekerooger & Jim,

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


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved