在目录末尾添加斜杠 +更多(htaccess)
这超出了我的水平,我需要一些帮助。
在 htaccess 中为以下内容制定重定向规则...
- 如果
example.com/1stleveldirectory
不以斜杠结尾,请添加一个。 - 如果
example.com/1stleveldirectory/
以斜杠结尾,则不要添加任何内容。 - 如果
example.com/1stleveldirectory/file
像这样添加 .html。 - 如果
example.com/1stleveldirectory/file.html
是这样的,则不要添加任何内容。
没有超过第一级的可公开访问的目录
谢谢!
编辑:我应该说我已经在文件顶部有这个代码。
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.([^.]+.[^.]+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Options +FollowSymLinks
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?cat=$1&name=$2 [L]
RewriteRule ^([^/]*)/$ /index.php?cat=$1 [L]
This is beyond my level and I need some help.
In the htaccess make redirect rules for the following...
- if
example.com/1stleveldirectory
doesn't end in a slash add one. - if
example.com/1stleveldirectory/
ends in a slash don't add anything. - if
example.com/1stleveldirectory/file
is like this add .html. - if
example.com/1stleveldirectory/file.html
is like this don't add anything.
There are no publicly accessible directories past the first level
Thanks!
EDIT: I should have said I already have this code at the top of the file.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.([^.]+.[^.]+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Options +FollowSymLinks
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?cat=$1&name=$2 [L]
RewriteRule ^([^/]*)/$ /index.php?cat=$1 [L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这些规则:
Try these rules: