Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

mod_rewrites with Firefox, Opera & Safari

...work fine with IE

8:53 am on Sep 4, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 25, 2003
votes: 0

I use mod_rewrite on /folder/ for several php dynamic pages using:

RewriteRule products\/(.+)\.html$ /folder/products.php?productid=$1 [NC,L]

which works fine in all browsers, but I can't get them to go to the error page when someone tries to access a product that no longer exists. I've placed "ErrorDocument 404 /404.html" in .htaccess and even scripted the products.php file with:

$errorDocument404 = '/404.html';
if (!mysql_num_rows($res)) {
header("HTTP/1.0 404 Not Found");
include $errorDocument404;

but no matter what, even though both methods work fine in IE none of the three browsers Firefox, Opera & Safari will go to the error page. They all display blank pages except for Safari which outputs:

The page you opened redirected you to a page that isn’t supported by Safari. Safari can’t open the page “” because it cannot redirect to locations starting with “(null):”

I don't get what it means. Has anyone else come across this?

6:53 pm on Sept 4, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 18, 2004
votes: 0

The 404 Error Directive may be overiding the mod_rewrite in your htaccess. As the page does not exist and is being redirected by the mod_rewite, the 404 error may be returned by default. Try deleting this from your htaccess or moving it to after the mod_rewite rule.
7:03 pm on Sept 4, 2005 (gmt 0)

Senior Member from CA 

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

joined:Aug 31, 2003
votes: 6

One good test would be to install the "Live HTTP headers" extension for Firefox. If you try to access a deleted page with the extension's window open, you can record the headers sent between browser and server. This is a great tool for debugging problems such as this.