htaccess的国防部重写301重定向

问题描述:

我想: 与国家301重定向到目录中,例如其中不包含文件名中所有链接(不.HTML,.JPG,.PNG,的CSS):A HREF http://mysite.com/article - > http://mysite.com/article/一> 但是, http://mysite.com/article/article-15.html 不是重定向。 什么regulat EX pression我必须写为.htaccess添加斜线虚拟目录?

I want: all links which not contained filename (not .html, .jpg, .png, .css) redirect with state 301 to directory, for example: http://mysite.com/article -> http://mysite.com/article/ But http://mysite.com/article/article-15.html not redirects. What regulat expression I must write to .htaccess for adding slash to virtual directories?

我认为以下可能的工作:

I think the following might work:

RewriteEngine on   
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]

当谈到mod_rewrite的我也不能肯定没有测试,但...

When it comes to mod_rewrite I can never be sure without testing though...