[英]How can i redirect one url to another url with htaccess file?
I want redirect from domain.com/temp/xyx/tech-specs to domain.com/temp/xyx/tech-specs/pemf-ts through htaccess. 我想通过htaccess从domain.com/temp/xyx/tech-specs重定向到domain.com/temp/xyx/tech-specs/pemf-ts。 I tried below code but it is not redirecting
我尝试了以下代码,但未重定向
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]
You are using HTTP_HOST
variable but what you need to match is REQUEST_URI
. 您正在使用
HTTP_HOST
变量,但需要匹配的是REQUEST_URI
。 Also keep redirect rule before internal rewrite rule. 还要在内部重写规则之前保留重定向规则。
Have it like this: 像这样:
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.