BASE URI in friendly 404 page

New to mod_rewrite? This is a good place to start.

BASE URI in friendly 404 page

Postby santiscle » Wed Apr 29, 2009 9:32 am

Hello.

In a content management system written in PHP, I have an .htacces file with this Mod Rewrite configuration:

Code: Select all
Options + FollowSymLinks
RewriteEngine On
RewriteCond %(SCRIPT_FILENAME)!-f
RewriteCond %(SCRIPT_FILENAME)!-f
RewriteRule ^(.*)$ resolv.php [L]


The purpose is to catch in resolv.php the requests for nonexistent files or directories.

If, for example, a user makes a request to this URL:

http://example.com/cms/inexistent

everything works fine. Mod Rewrite loads the file http://example.com/cms/resolv.php, and then a friendly 404 page is shown.

But if the requested URL is:

http://example.com/cms/ine/xis/tent

then I have a problem. Mod Rewrite loads http://example.com/cms/resolv.php file, which is what I want, but in the friendly 404 page, the BASE URI of the HTML becomes http://example.com/cms/ine/xis/ and then, soft referenced images and links stop working.

The question is:

Can Mod Rewrite be configured in a form in wich the BASE URI becomes the same of resolv.php in case the user request for a nonexistent directory or a file in a nonexistent directory?

Thanks.
santiscle
 

Postby santiscle » Wed Apr 29, 2009 10:21 am

Hello again.

Found a response in the FAQs:

viewtopic.php?p=10709#10709

If I add a <base> URI in my 404 page, all works fine. I evaluate now is this is a posible/realistic solution in my CMS.

Thank you anyway!
santiscle
 


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 4 guests

cron