[英].htaccess rewrite subfolders to remove /index
I have some htaccess rules which rewrite friendly URLs. 我有一些htaccess规则可以重写友好的URL。 Everything is working apart from one thing.
一切都是一件事情。
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R] # <- for test, for prod use [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*?)/?$ $1.html [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L,R=301]
This is a site with language subfolders, eg: 这是一个具有语言子文件夹的网站,例如:
/fr/about.html
/en/about.html
With the above htaccess rules these urls come out like: 有了上述htaccess规则,这些网址就会出现:
/fr/about
/en/about
However this also means my index pages URLs look like: 但这也意味着我的索引页面URL如下所示:
/fr/index
/en/index
What I would like, is for /index the URL looks like 我想要的是/ index,URL看起来像
/fr
/en
Which would mean they respect the trailing slash part of my above htaccess but remove index
from the URL. 这意味着他们尊重我上面htaccess的结尾斜杠部分,但从URL中删除了
index
。
Any help much appreciated! 任何帮助,不胜感激!
Try to add (before RewriteCond %{THE_REQUEST} ^
...): 尝试添加(在
RewriteCond %{THE_REQUEST} ^
...之前):
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*?)/index(\.html)?[\s?] [NC]
RewriteRule ^ %1 [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.