.htaccess无法重定向url
我们有一个项目,这是开发开放式车。我们有一些URL,若用户点击这些URL,那个么系统将把用户重定向到另一个指定的URL。为此,我们在.htaccess文件中做了一些更改 这是我的原始.htaccess文件代码:.htaccess无法重定向url,.htaccess,.htaccess,我们有一个项目,这是开发开放式车。我们有一些URL,若用户点击这些URL,那个么系统将把用户重定向到另一个指定的URL。为此,我们在.htaccess文件中做了一些更改 这是我的原始.htaccess文件代码: RewriteBase / RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] RewriteRule sitemap.xml /index.php
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule sitemap.xml /index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
现在,为了重定向,我们添加了以下行:
Redirect 302 http://www.covermale.com/index.php?route=product/manufacturer/info&manufacturer_id=23 http://www.covermale.com/obviously
但我们的系统无法重定向到。有人能告诉我们,上面的规则有问题吗?试试这个例子:
RewriteEngine on
RewriteCond %{query_STRING} ^route=product/manufacturer/info&manufacturer_id=23$
RewriteRule ^index\.php$ http://www.covermale.com/obviously? [R=301,L]
您的.htaccess如下所示:
RewriteEngine on
RewriteBase /
RewriteCond %{query_STRING} route=product/manufacturer/info&manufacturer_id=23 [NC]
RewriteRule ^index\.php$ /obviously? [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule sitemap.xml /index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
从标志中删除空格:
RewriteRule^index\.php$/显然?[R=301,L]
不幸的是,您的解决方案也无法重定向URL。请注意,[L]标志只能设置一次(最后一条规则)。您的回答中没有提到域“covermale.com”,所以我怀疑这会在第一个重定向规则中起作用。如果源和目标URL为同一个域,则无需提及域名。这实际上是一个很好的观点,我这里有一个类似的问题,但在我的情况下,域是不同的,所以不确定如何应用您的解决方案,您认为您可以看一下吗?