2015-11-07 37 views
1

请帮我解决这种情况。正确.htaccess

我有一个共享主机,我想调整我的.htaccess文件的好方法。 我有以下网页:

  1. index.html
  2. news.html
  3. 页面,如post-01-11-2015.html

现在我想:

  1. 删除所有.html所有网址末尾
  2. 如果当前页面是index.html,我想看看example.com,不example.com/index.html
  3. ,当我在news.html页打开post-01-11-2015.html,我想看看在浏览器的URL像example.com/posts/2015/11/01。我想输入example.com/posts/2015/11/01我想看页。
  4. 任何你建议我,是非常好的。

如果您需要任何信息,请告诉我。

现在有这个模块代码,但我得到错误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

你的htaccess更改为:

RewriteBase/
RewriteRule ^/$ index.html [QSA,L] 
RewriteRule ^post/([0-9_-]+)/([0-9_-]+)/([0-9_-]+)/$ post-$3-$2-$1.html [QSA,L] 
+0

是......不工作 – platinumfives