开发者

Problem with redirection selected path to different domain

开发者 https://www.devze.com 2023-04-05 22:13 出处:网络
I have this rules inside my .htaccess file what I want to obtain is to redirects all request that don\'t match secure.x.com/en/account?x=1 to x.com/en/account?x=1 and all request like se开发者_运维问

I have this rules inside my .htaccess file what I want to obtain is to redirects all request that don't match secure.x.com/en/account?x=1 to x.com/en/account?x=1 and all request like se开发者_运维问答cure.x.com/en/account/xxxx shouldn't be redirected.

Options Indexes FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} secure.x.com [NC]
RewriteCond %{REQUEST_URI} !^[a-z-]{2,8}/account [NC]
RewriteRule (.*) http://x.com%{REQUEST_URI} [R=301,L]

RewriteRule !\.(css|gif|htm|html|ico|jpg|js|pdf|php|png|swf|txt|xml)$ index.php

This rule works fine for url like secure.x.com/en/noaccount => redirect to x.com/en/noaccount

But not for request like secure.x.com/en/account

What is the problem with that rule?


I found solution for my problem. I don't know if this is optimal solution but it works.

Options Indexes FollowSymLinks
RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [S=3]

RewriteCond %{HTTP_HOST} local.secure.x.com [NC]
RewriteCond %{REQUEST_URI} ![a-z]{2,8}/account [NC]
RewriteRule ^(.*)$ http://local.x.com/$1 [R=301,L]

RewriteRule !\.(css|gif|htm|html|ico|jpg|js|pdf|php|png|swf|txt|xml)$ index.php

If someone have better idea let me know. tnx.

0

精彩评论

暂无评论...
验证码 换一张
取 消