.htaccess - url结束字符(/)

时间:2015-05-30 02:49:52

标签: .htaccess url mod-rewrite

请帮我修改.htaccess。如何在网址中添加结束字符[/]。

现在.htaccess做了 www.mysite.cz/about.php> www.mysite.cz/about
www.mysite.cz/about/> www.mysite.cz/about

我需要这个 www.mysite.cz/about.php> www.mysite.cz/about/
www.mysite.cz/about> www.mysite.cz/about /

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.cz$
RewriteRule (.*) http://www.mysite.cz/$1 [R=301,L]
RewriteRule ^index.php$ http://mysite.cz/$1 [R=301,L]      

RewriteCond %{THE_REQUEST} \ /+(.+)(?:/|\.php)(?:\?|\ )
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /%1 [L,R=301]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+)$ $1.php    [L]

1 个答案:

答案 0 :(得分:1)

试试这个:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.cz$
RewriteRule (.*) http://www.mysite.cz/$1 [R=301,L]
RewriteRule ^(index.php)$ http://mysite.cz/$1 [NC,R=301,L]      

RewriteCond %{THE_REQUEST} \ /+(.+)(?:/|\.php)(?:\?|\ )
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /%1/ [NC,L,R=301]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+)/?$ $1.php    [NC,L] 

这会在路径末尾添加一个尾部斜杠:

 www.mydomain.cz/about.php

将重定向到

  www.mydomain.cz/about/