2012-08-08 76 views
0

我正在做一个php项目。动态网址将被更改为搜索引擎友好的url。我正在创建htaccess文件来重写网址。我不熟悉.htaccess。 iam尝试在网址中插入bakslash。 如果URL不是以 “/” 或 “的.html” 然后在last.Please帮助添加一个反斜杠查询的网址与 “/” 或 “的.html在网址的末尾插入斜杠htaccess

END END

我现在想这个代码

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !\..+$ 
RewriteCond %{REQUEST_URI} !/$ 
RewriteRule (.*) http://www.example.com/$1/ [R=301,L] 

这个代码只插黑斜杠为http://www.example.com/hh情况。但我会尝试在任何文档根

如添加反斜线

http://www.example.com/hh/yyy - http://www.example.com/hh/yyy/ 
http://www.example.com/h  - http://www.example.com/h/ 
+0

当你说[“反斜杠”(HTTP:// EN。 wikipedia.org/wiki/Backslash)你的意思是[正斜杠](http://en.wikipedia.org/wiki/Slash_%28punctuation%29),对吧? – MvG 2012-08-09 12:49:59

回答

0

给一个尝试以下操作:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^/(.*[^/]+)$ http://www.example.com/$1/ [R=301,L] 
+0

这只适用于** http://www.example.com/hdd**的情况下,它不会重定向** http://www.example.com/hdd/hh**。 – user1572105 2012-08-08 19:07:09