Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Recently I've encountered an issue where some pages 404 when accessed via their cruftless paths.

The same pages work when a query string, like ?1234 or index.php is appended to the path.

Example: - Fail - Success - Success

I'm not sure if this is a mod_rewrite or a caching issue.

Here is the content of my .htaccess file:

# Use PHP5.3 Single php.ini as default
AddHandler application/x-httpd-php53 .php

#ExpiresDefault A0
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
Header set Pragma "no-cache"

DirectoryIndex index.php index.html

RewriteEngine on

RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [R=301,NC] 

# Error documents
ErrorDocument 404 /404.php
ErrorDocument 403 /404.php
ErrorDocument 500 /500.php

# compress a few file extensions
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/html

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch ^MSIE !no-gzip !gzip-only-text/html

<IfModule mod_expires.c>
    # explicitly disable caching for scripts and other dynamic files
    <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
        Header unset Cache-Control

Redirect /mikes
Redirect /code-of-interest

# Redirect all old photo pages to the tiny new one
RewriteCond %{REQUEST_URI} ^/photos/[a-z\/]+$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ [R=301,L] 
share|improve this question
Are there any errors generated in Apache's error log? You may also want to turn on the mod_rewrite log--its possible one of your rules--or a global rule--is affecting what's happening. –  Andrew M. Jan 3 '12 at 4:29

1 Answer 1

This look kind of weird, we would need the errors generated from the rewrite module log (see for additional info how to enable rewritelog directive). The problem look like restricted to your code-complete page as all the accessible link from the menu does give valid URL/pages.

The 'quick-fix/hack' way would be to add redirects for that page. I do NOT advocate that way, but sometimes, we just want it to work...

Redirect /code/plugins/code-complete /code/plugins/code-complete/index.php
Redirect /code/plugins/code-complete/ /code/plugins/code-complete/index.php

Also, as a side-note, you are losing the "/" in the original query. I would change the

RewriteRule ^(.*)$$1 [R=301,NC] 


RewriteRule ^(.*)$$1 [R=301,NC] 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.