Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- index.php redirect breaking 404 pages.


g1smd - 4:55 pm on Dec 7, 2012 (gmt 0)


There is a way.

Stop the htaccess file from redirecting those requests and only those requests, by using a RewriteCond on the non-www/www canonicalisation ruleset, and then set up the PHP functionality at the beginning of the index.php file, as follows:

- if there is no page name found in the database matching the request, send 404 header and HTML page with error message,
- if the page name matches a valid database entry, but the wrong hostname was requested, send a 301 redirect to the correct URL,
- if the page name matches a valid database entry and the correct hostname was requested, send 200 OK status and the page of content.

There is no way to send the 404 status from the htaccess rules. You have to let the PHP script handle that part of the functionality, and specifically exclude the relevant htaccess rules from dealing with the request and redirecting it.


Thread source:: http://www.webmasterworld.com/apache/4520914.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com