[BlueOnyx:08724] Re: Rewrite oddity

Christoph Schneeberger cschnee at box.telemedia.ch
Tue Oct 4 10:49:15 -05 2011


Colin Jack wrote:
> I would be interested to hear comments on the following. We have a user who was having problems getting his website working. He sent me the following explanation as to what was happening and I wondered whether anybody could shed some light as to why? On a BX 5106 box.
>
> Quote:
>
> "Ok, All pages on the site are generated through a script called page.php, this script needs a query string parameter (called pid) to work out which page on the website to build and show to the user.  All the navigation code in the CMS knows to call each page using the scheme:/page/pageid/some_descriptive_text, this both makes the URLs look a little more friendly and helps with SEO.  There is then the .htaccess file with some rewrite rules which take requests for /page/pageid/some_descriptive_text and convert them into /page.php?pid=pageid, which is all fairly standard stuff.
>  
> The problem we're having is that before any of the rewrite rules get called and this conversion happens, something (I think possibly at Apache or php.ini level) is catching the /page/ part of the requested URL and converting it straight to /page.php meaning that the rewrite rules are never fired and the capture of the pageid query string parameter within the URL doesn't happen, thus CMS doesn't know what page to retrieve from the database and the site breaks.
>  
> The reason I think this is server level is because it seems to do it with other pages as well so if we set up a page called /test.php and then call /test/ in the browser, we still get the contents of /test.php even though that's not what we asked for."
>
> He has managed a work around:
>
> " Interestingly, I've just noticed that calling the REQUEST_URI server variable from within PHP returns the originally requested URL ... I have been able to extract the page id from the REQUEST_URI variable if it's not available in the query string, and I have added that code into the main code tree ..."
>
> But I would be interested as to why this is happening in case it rears its head again!
>
>   

Check out the Apache manual part about MultiViews. I guess that's whats
happening to you. Disabling MultiViews for this site should also prevent
apache from parsing /test/ as /test.php (and btw also test.html etc.).
Basically if MultiViews search is done whenever you request a directory
that does not exist in the filesystem apache tries to add several
extensions to your request and looks if it can satisfy your request this
way.

Just try with an empty website, add a test.html and request the URL
/test it will deliver you not a 404 but the contents of test.html until
you disable Multiviews there - then you'll get the 404 you actually
expected.

This is just from the top of my head...

Hth,
Christoph



More information about the Blueonyx mailing list