2015-05-22 119 views
1

RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*[^/])$ /$1/ [L,R=301]如何在htaccess的URL末尾添加斜槓?

當我使用這個在它被重定向像example.com//

末尾添加斜線但我想我的重定向URL

www.example.com 

www.example.com/ 

任何人都可以告訴我該怎麼做?

回答

0

您是否嘗試過搜索論壇?

RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301] 

來源:.htaccess Rewrite to Force Trailing Slash at the end

更多問題:

Htaccess: add/remove trailing slash from URL

Add Trailing Slash .htaccess

.htaccess if url not ends with extension, add slash at the end

+0

'RewriteBase/ 的RewriteCond%{}的index.php !-f RewriteCond%{HTTP_HOST}!index.php RewriteCond%{HTTP_HOST}!(。*)/ $ RewriteRule^[^ /] * $ http://%{HTTP_HOST}/$ 1/[L,R = 301]'當我使用這個我得到兩個斜線在URL的末尾,但我只需要一個斜線,你能建議我嗎? – user3264805