htaccess的mod-rewrite301重定向 [英] .htaccess mod rewrite 301-redirect
问题描述
我想: 与国家301重定向到目录中,例如其中不包含文件名中所有链接(不.HTML,.JPG,.PNG,的CSS):A HREF <=http://mysite.com/article相对=nofollow > 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...
这篇关于htaccess的mod-rewrite301重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!