请在这种情况下帮助我。
我有一个共享主机,我想以良好的方式调整我的.htaccess
文件。
我有以下页面:
index.html
news.html
post-01-11-2015.html
现在我想:
.html
index.html
,我想看到example.com
,而不是example.com/index.html
post-01-11-2015.html
中打开news.html
时,我想在浏览器网址中看到example.com/posts/2015/11/01
。example.com/posts/2015/11/01
时,我想看到页面post-01-11-2015.html
。如果您需要任何信息,请告诉我。
现在有了这个模块代码,但我收到错误cycle redirection
。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://www.example.com [R=301,L]
RewriteRule ^post-(\d+)-(\d+)-(\d+)\.html$ /posts/$1/$2/$3 [R=301,L,NC]
RewriteRule post-(\d+)-(\d+)-(\d+)\.html$ posts/$1/$2/$3 [R=301,L,NC]
RewriteRule (.+)\.html$ /$1 [R=301,L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L,QSA]
</IfModule>
非常感谢你!希望你帮助我最好的方式!
答案 0 :(得分:0)
将您的htaccess更改为:
RewriteBase /
RewriteRule ^/$ index.html [QSA,L]
RewriteRule ^post/([0-9_-]+)/([0-9_-]+)/([0-9_-]+)/$ post-$3-$2-$1.html [QSA,L]