我在htaccess中编写代码以在url中添加尾部斜杠,同时应用重定向。 我的代码是 -
#Add slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://example.com/$1/ [L,R=301]
Redirect 301 /social-media-consultant http://example.com/seo-consultant/
Redirect 301 /uiux-developers http://example.com/graphics-designer/
现在,问题在于当我编写用于添加斜杠的代码时,重定向将停止工作。
答案 0 :(得分:0)
mod_rewrite
的规则。这样做:
RewriteEngine On
RewriteRule ^social-media-consultant$ http://example.com/seo-consultant/ [L,NC,NE,R=301]
RewriteRule ^uiux-developers$ http://example.com/graphics-designer/ [L,NC,NE,R=301]
#Add slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^ http://example.com/%{REQUEST_URI}/ [L,R=301,NE]
确保在测试此更改之前清除浏览器缓存。