2015-01-26 137 views
0

我想重定向的网址不以slash结尾为slash

注:的.htaccess是mysite目录如何使用mod重写来重定向URL?

的.htaccess

<need help here> 

不是不想URL

http://localhost/mysite/index.php 
http://localhost/mysite/blog 
http://localhost/mysite/blog/110084 

所需的URL

http://localhost/mysite/ 
http://localhost/mysite/blog/ 
http://localhost/mysite/blog/110084/ 

非常感谢。

+0

不清楚你的问题是什么。你目前的规则有什么问题? – anubhava 2015-01-26 19:35:25

+0

请详细说明迄今为止编写的规则有哪些问题,SO是针对特定问题而不是代码编写服务提出问题。提供一些不符合当前规则的示例URL将会使这成为一个真正的问题 – RobV 2015-01-26 19:35:54

+0

它不是关于规则,而是关于重定向的URL,而不是以'slash'结尾的'slash'结尾,例如:'mysite' - >'mysite /'或'mysite/blog' - >'mysite/blog /'。 – Marcus 2015-01-26 19:42:55

回答

0
RewriteEngine on 
RewriteBase /Application 
RewriteCond $1 !^(index\.php|images|table-images|robots\.txt|styles|js|uploads) 
RewriteRule ^(.*)$ index.php/$1 [L] 
+1

尝试添加关于您的代码的简要说明。 – ianaya89 2015-01-26 20:23:26

0

您可以使用此规则为第一个规则略低于RewriteEngine On行添加斜线非文件:

# add a trailing slash to directories 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L,R=302]