htaccess的重写条件斜线只对特定目录斜线、重写、只对、条件

由网友(一别两宽)分享简介:我有这样的规则,它的伟大工程,并增加了斜线为我的网站上每个目录。如何添加结尾的斜杠只有特定的目录如/场/?我不希望每个目录/路径有一个结尾的斜线。的RewriteCond%{REQUEST_URI} ^ / [^ \。] + [^ /] $重写规则^ $ HTTP(*)://%{HTTP_HOST} / $ 1 /...

我有这样的规则,它的伟大工程,并增加了斜线为我的网站上每个目录。 如何添加结尾的斜杠只有特定的目录如/场/?我不希望每个目录/路径有一个结尾的斜线。

 的RewriteCond%{REQUEST_URI} ^ / [^ 。] + [^ /] $
  重写规则^ $ HTTP(*)://%{HTTP_HOST} / $ 1 / [R = 301,L]
 

解决方案

 的RewriteCond%{REQUEST_URI} ^ /(课程|富|酒吧)$
重写规则^ $ HTTP(*)://%{HTTP_HOST} / $ 1 / [R = 301,L]
 

应工作,其中课程是要一个斜线添加到目录。

Apache开启.htaccess的方法

I have this rule which works great and adds a trailing slash for every directory on my site. How Can I add trailing slashes for only certain directories such /courses/ ? I don't want every directory / path to have a trailing slash.

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

解决方案

RewriteCond %{REQUEST_URI} ^/(courses|foo|bar)$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]

Should work where courses, foo and bar are directories that you want to add a trailing slash to.

阅读全文

相关推荐

最新文章