假设我试图从/table/09重定向到/housing关联,下面的代码并不是重定向。我将包括整个.htaccess文件。这是一个拉拉维尔的装置。另一个重定向工作,即所有urls都被定向到index.php,尾随斜杠被移除:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^fabric [NC,OR]
RewriteCond %{HTTP_HOST} ^www.fabric [NC]
RewriteRule ^/table/[0-9]{2} /housing-associations [R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
有没有人有任何想法。我搞不懂为什么这个不行?
谢谢
发布于 2015-04-30 16:49:22
这应该适用于你:
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?fabric [NC]
RewriteRule ^table/[0-9]{2} /housing-associations [R=301,L]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]两个HTTP_HOST条件合并为一个,其中www.是可选的。/table中的前导斜杠已被删除。最后,添加了L标志以防止index.php规则运行。如果L标志不存在,您将得到来自Apache的永久移动消息。
https://stackoverflow.com/questions/29971089
复制相似问题