我试图得到以下效果(使用本本地文件的http://本地主机/ [COMPANY_NAME] / [PROJECT_NAME] /.htaccess
):
的http://本地主机/ [COMPANY_NAME] / [PROJECT_NAME] /页1(加斜杠)
HTTP://本地主机/ [COMPANY_NAME] / [PROJECT_NAME] /页1 /(什么都不做)
HTTP://本地主机/ [COMPANY_NAME] / [PROJECT_NAME] /页,1 /子页面-1(加斜杠)
http://www.example.com/page-1(加斜杠)LT; BR />
http://www.example.com/page-1/(什么都不做)
等等
我要完成的事情是,这个的.htaccess不需要路径的http://本地主机/ [COMPANY_NAME] / [PROJECT_NAME] /
再使我没有编辑这个它已经每次上传。
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^(。* [^ /])/ $ 1 / [L,R = 301]
我发现code以上的位置:添加尾随斜线网址的,但它仅使得可以动态地使用HOST和丢弃的路径。是否有人的解决方案来实现这种效果呢?
解决方案 的RewriteCond%{REQUEST_URI}!(/ $ | )
重写规则(。*)%{REQUEST_URI} / [R = 301,L]
I'm trying to get the following effect (using this local file http://localhost/[company_name]/[project_name]/.htaccess
):
http://localhost/[company_name]/[project_name]/page-1 (adds slash)
http://localhost/[company_name]/[project_name]/page-1/ (does nothing)
http://localhost/[company_name]/[project_name]/page-1/subpage-1 (adds slash)
http://www.example.com/page-1 (adds slash)<br />
http://www.example.com/page-1/ (does nothing)
etc.
The thing I want to accomplish is that this .htaccess doesn't need the path http://localhost/[company_name]/[project_name]/
anymore so that I don't have to edit this each time it's been uploaded.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]
I found the code above here: Add Trailing Slash to URLs, but it only makes it possible to use the HOST dynamically and discards the path. Does someone a solution to accomplish this effect?
解决方案RewriteCond %{REQUEST_URI} !(/$|.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
上一篇:禁用所有的CGI(PHP,PERL,...)使用的.htaccess目录有的、目录、CGI、PHP
下一篇:重定向www.subdomain.example.com到subdomain.example.com重定向、www、subdomain、example