1
  • Converting large static site to Drupal 6.2
  • Page urls are now aliased like "folder/" "folder/subfolder/"
  • Problem is hundreds of inbound links that point to "sub.example.com/folder/index.htm"

I'd rather not have to include that filename in my aliases and was hoping I could just htaccess rewrite those requests to the base directories since they're all the same format but I can't for the life of me get it to work.

Been trying to use this, placed before Drupal's rewrite rules in .htaccess:

RewriteCond %{THE_REQUEST} ^GET\ /.*/index\.(php|html)\ HTTP
RewriteRule (.*)index\.(php|html)$ /$1 [R=301,L]

or this:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html|php)?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.(html|php)?$ http://sub.example.com/$1 [R=301,L]

1 Answer 1

0

Well I feel dumb, thought I had tried it with the L and R swapped but I guess not, this worked perfect for both bits I tried.

RewriteCond %{THE_REQUEST} ^GET\ /.*/index\.(php|html)\ HTTP
RewriteRule (.*)index\.(php|html)$ /$1 [L=301,R]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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