什么我需要做下面的重写规则,使其所以它的工作原理是否他们是在网址的结尾?

斜杠

即。 http://mydomain.com/content/featured 要么 http://mydomain.com/content/featured/

RewriteRule ^content/featured/ /content/today.html 
有帮助吗?

解决方案

使用$来标记所述串的端部和所述?标记前面的表达式要重复零轮或一个次:

RewriteRule ^content/featured/?$ content/today.html

不过,我建议你坚持一个符号,纠正拼写错误:

# remove trailing slashes
RewriteRule (.*)/$ $1 [L,R=301]

# add trailing slashes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ $0/ [L,R=301]

其他提示

简单的方法来做到这一点:

RewriteEngine On
RewriteBase / 
RewriteRule ^content/featured(\/||)$ /content/today.html [L,R=301,NC] 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top