由网友(眼中有春秋)分享简介:什么我需要做下面的重写规则,使其所以它的工作原理是否不是自己是一个斜线网址的结尾?IE浏览器。http://mydomain.com/content/featured 要么http://mydomain.com/content/featured/ 重写规则^含量/功能/ /content/today.html解决方...![访问路径问题 带斜杠和不带斜杠的区别](https://p.xsw88.cn/allimgs/daicuo/20230902/115.png)
什么我需要做下面的重写规则,使其所以它的工作原理是否不是自己是一个斜线网址的结尾?
IE浏览器。 http://mydomain.com/content/featured 要么 http://mydomain.com/content/featured/
重写规则^含量/功能/ /content/today.html
解决方案
使用了 $
标记字符串的结束和?
标记的preceding EX pression被重复零次或一次:
重写规则^含量/功能/?$内容/ today.html
![访问路径问题 带斜杠和不带斜杠的区别](https://p.xsw88.cn/allimgs/daicuo/20230902/115.png)
不过,我建议你坚持一个符号,纠正拼写错误:
#删除尾随斜线
重写规则(。*)/ $ $ 1 [L,R = 301]
#添加结尾的斜杠
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则。* [^ /] $ $ 0 / [L,R = 301]
What do I need to do to the following rewrite rule to make it so it works whether or not their is a slash at the end of the URL?
ie. http://mydomain.com/content/featured or http://mydomain.com/content/featured/
RewriteRule ^content/featured/ /content/today.html
解决方案
Use the $
to mark the end of the string and the ?
to mark the preceding expression to be repeated zero or one times:
RewriteRule ^content/featured/?$ content/today.html
But I recommend you to stick to one notation and correct misspelled:
# remove trailing slashes
RewriteRule (.*)/$ $1 [L,R=301]
# add trailing slashes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ $0/ [L,R=301]
相关推荐
最新文章