[英]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.