.htaccess Wordpress rewrites not sending non existing pages 404

Discussion in 'Apache' started by BamaStangGuy, May 14, 2007.

  1. #1
    I have a url that doesn't exist yet when someone clicks on the url it doesn't give a 404 page not found it simply just loads the main page instead.

    An example: http://www.mustangevolution.com/articles/shockandstrutinstall/

    the .htaccess for that folder:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.mustangevolution\.com
    RewriteCond %{REQUEST_URI} articles/
    RewriteRule ^(.*)$ http://www.mustangevolution.com/articles/$1 [L,R=301]
    RewriteCond %{REQUEST_URI} /+[^\.]+$
    RewriteCond %{REQUEST_URI} /articles/
    RewriteRule ^(.+[^/])$ /articles/$1/ [R=301,L]
    RewriteBase /articles/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /articles/index.php [L]
    Code (markup):
    The .htaccess for the root:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.mustangevolution\.com
    RewriteRule ^(.*)$ http://www.mustangevolution.com/$1 [L,R=301]
    RewriteCond %{REQUEST_URI} /+[^\.]+$
    RewriteRule ^(.+[^/])$ /$1/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    Code (markup):
    Why does this not give a 404?
     
    BamaStangGuy, May 14, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Because they both rewrite all requests for files that don't exist to the index.php page. This is how the scripts can use pretty URLs - it can generate a URL in any format and have it rewritten to the index script. The index script then interprets the URL and finds the corresponding page, regardless of the chosen format for the links.

    I would have expected the scripts to send out a 404 when the requested page is not found but it sounds like they just show the index instead.
     
    rodney88, May 14, 2007 IP