我正在尝试重定向网址,因此,如果该网址是http://foobar.com/admin/bla要重定向到http://foobar.com/admin/bla/
这是.htaccess文件的内容
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|assets|stylesheets|scripts|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^(.*)/$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
问题是重定向不起作用。当我输入http://foobar.com/admin/bla时,响应为200。我想要的是将301重定向到带有/末尾的url我在做什么错了?
这应该工作
RewriteEngine on
RewriteBase /
# if it's an existing folder or file, do nothing
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]
# if no trailing slash then add it
RewriteRule ^(.+)([^/])$ $1$2/ [L,R=301]
# internally rewrite url to index.php controller
RewriteRule ^(.*)$ index.php/$1 [L]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句