Forum Moderators: phranque
Basically, if I try to load a page that doesn't exist on my site it does not return a normal 404 response. Its ok for directories however, just pages.
For example:
mysite.com/blahblah.html - does NOT show 404 response
mysite.com/blahblah - DOES show 404 response
My site in hosted on a shared Linux server and is written in XHTML.
In case it is needed, my current .htaccess shows this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.net [NC]
RewriteRule (.*) http://www.example.net/$1 [R=301,L]
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
RewriteEngine On
RewriteBase /
#########################################################
# forum SEO REWRITE RULES#
#####################################################
# FORUMS PAGES
########################
# FORUM INDEX (un-comment if used)
# RewriteRule ^forum/index\.html$ /forum/index.php [QSA,L]
# FORUM PROTECTION RULE
# RewriteRule ^forum/.*/([^/]+\.html)$ /forum/index.php [R=301,L]
# CATEGORIES
RewriteRule ^forum/cat([0-9]+)\.html$ /forum/index.php?c=$1 [QSA,L]
# PAGINATED FORUM
RewriteRule ^forum/forum([0-9]+)-([0-9]+)\.html$ /forum/viewforum.php?f=$1&start=$2 [QSA,L]
# FORUM
RewriteRule ^forum/forum([0-9]+)\.html$ /forum/viewforum.php?f=$1 [QSA,L]
# PAGINATED TOPIC
RewriteRule ^forum/topic([0-9]+)-([0-9]+)\.html$ /forum/viewtopic.php?t=$1&start=$2 [QSA,L]
# TOPIC
RewriteRule ^forum/topic([0-9]+)\.html$ /forum/viewtopic.php?t=$1 [QSA,L]
# POST
RewriteRule ^forum/post([0-9]+)\.html$ /forum/viewtopic.php?p=$1 [QSA,L]
#PROFILES
RewriteRule ^forum/member([0-9]+)\.html$ /forum/profile.php?mode=viewprofile&u=$1 [QSA,L]
# END forum PAGES
#####################################################
[edited by: jdMorgan at 2:47 am (utc) on April 30, 2008]
[edit reason] Removed and/or examplified links [/edit]
### ASIDE ###
You could probably 'stream line' you code a little:
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.example\.net)?$
RewriteRule (.*) http://www.example.net/$1 [R=301,L]
#########################################################
# forum SEO REWRITE RULES#
#####################################################
# FORUMS PAGES
########################
# FORUM INDEX (un-comment if used)
# RewriteRule ^forum/index\.html$ /forum/index.php [QSA,L]
# FORUM PROTECTION RULE
# RewriteRule ^forum/.*/([^/]+\.html)$ /forum/index.php [R=301,L]
# CATEGORIES
RewriteRule ^forum/cat([0-9]+)\.html$ /forum/index.php?c=$1 [QSA,L]
# PAGINATED FORUM
RewriteRule ^forum/forum([0-9]+)-([0-9]+)\.html$ /forum/viewforum.php?f=$1&start=$2 [QSA,L]
# FORUM
RewriteRule ^forum/forum([0-9]+)\.html$ /forum/viewforum.php?f=$1 [QSA,L]
# PAGINATED TOPIC
RewriteRule ^forum/topic([0-9]+)-([0-9]+)\.html$ /forum/viewtopic.php?t=$1&start=$2 [QSA,L]
# TOPIC
RewriteRule ^forum/topic([0-9]+)\.html$ /forum/viewtopic.php?t=$1 [QSA,L]
# POST
RewriteRule ^forum/post([0-9]+)\.html$ /forum/viewtopic.php?p=$1 [QSA,L]
#PROFILES
RewriteRule ^forum/member([0-9]+)\.html$ /forum/profile.php?mode=viewprofile&u=$1 [QSA,L]
# END forum PAGES
#####################################################
You only need one RewriteEngine on per file. (It does not turn off.)
You do not need a RewriteBase, because your rewrites are 'server relative' URLs, and the base indicated / as the base. (Basically it was redundant.) If the right side of the rules were directory relative, you would want to use the base to indicate they should begin at the server root. (You could also remove the / from the right side of every rule and leave the base, but using full server relative URLs leaves less chance of error.)
### END ASIDE ###