[英]How can i redirect one url to another url with htaccess file?
我想通过htaccess从domain.com/temp/xyx/tech-specs重定向到domain.com/temp/xyx/tech-specs/pemf-ts。 我尝试了以下代码,但未重定向
RewriteEngine On
RewriteBase /temp/xyx/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^tech-specs$
RewriteRule ^$ tech-specs/pemf-ts [L,R=301]
您正在使用HTTP_HOST
变量,但需要匹配的是REQUEST_URI
。 还要在内部重写规则之前保留重定向规则。
像这样:
RewriteEngine On
RewriteBase /temp/xyx/
RewriteRule ^(tech-specs)/?$ $1/pemf-ts [L,R=301,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?_route_=$1 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.