开发者

.htaccess remove index.htm for requests on Drupal 6 site

  • 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 us开发者_运维技巧e 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]


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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜