Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

We recently switched formats for managing our 301s. For the most part, everything went well, but it seems to have stopped mod_speling from working properly. Here's what we changed:

old /var/www/html/.htaccess:

RewriteEngine on
RewriteBase /

# Change SHTML to HTML
RewriteRule ^(.*)\.shtml$ $1.html [R=permanent,L]

# Change PCF to HTML ('cause, you know, we probably have CMS users like that...)
RewriteRule ^(.*)\.pcf$ $1.html [R=permanent,L]

# Force WWW subdomain for all requests
RewriteCond %{HTTP_HOST} !^www.example.edu$ [NC]
RewriteRule ^(.*)$ http://www.example.edu/$1 [R,L]

# User accounts are on sun.example.edu
RedirectMatch ^/~(.*)$ http://sun.example.edu/~$1

# Remove index.html at the end of URLs
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule . %1 [R=301,NE,L]

Redirect 301 /academics/calendar2012-13.html http://www.example.edu/academics/calendar.html
Redirect 301 /academics/departments/   http://www.example.edu/majors/
Redirect 301 /academics/Pre-Medical.pdf http://www.example.edu/academics/Pre-Medicine.pdf
Redirect 301 ...

new /var/www/html/.htaccess:

RewriteEngine on
RewriteBase /

# Change SHTML to HTML
RewriteRule ^(.*)\.shtml$ $1.html [R=permanent,L]

# Change PCF to HTML ('cause, you know, we probably have CMS users like that...)
RewriteRule ^(.*)\.pcf$ $1.html [R=permanent,L]

# Force WWW subdomain for all requests
RewriteCond %{HTTP_HOST} !^www.example.edu$ [NC]
RewriteRule ^(.*)$ http://www.example.edu/$1 [R,L]

# User accounts are on sun.example.edu
RedirectMatch ^/~(.*)$ http://sun.example.edu/~$1

# Remove index.html at the end of URLs
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule . %1 [R=301,NE,L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) 404/$1

And then we added a new file at /var/www/html/404/.htaccess:

RewriteEngine on
RewriteBase /404

RewriteRule ^academics/calendar2012-13.html$    /academics/calendar.html    [R=302,L]
RewriteRule ^academics/departments/$    /majors/    [R=301,L]
RewriteRule ^academics/Pre-Medical.pdf$ /academics/Pre-Medicine.pdf[R=301,L]
RewriteRule ...

I do have (Webmin-based) access to the httpd.conf (though we don't want to store all our 301s there, if possible). We're running Apache 2.2.15 on RHEL 6 on a server in our own data center.

Like I said, the only problem we're seeing is that mod_speling isn't doing its magic anymore. The new format has so many advantages over the old that we really don't want to go back, but mod_speling is so nice to have that we'd also really like it to work if possible. Any ideas for how we might be able to fix mod_speling?

share|improve this question

1 Answer 1

mod_speling and mod_rewrite apply their rules during the same phase. If rewrite touches a URL it generally won't pass the url on to mod_speling. You can use the "pass through" [PT] flag on any rewrite rule that is preventing mod_speling from doing its magic. If the [PT] flag is in place, then mod_speling can still do its job.

The other thing that I do is put a script in place for the 404 handler. This allows me to examine the url in the script and issue redirects based on rules such as case sensitivity, truncation that can be inferred, characters appended after ".html" and so on. I stopped using mod_speling when I found I could implement a 404 handler that did a better job with the 404 errors that I was actually getting.

share|improve this answer

Your Answer

 
discard

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.