2015-01-26 54 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]