开发者

Setting up htaccess file for sub-folder redirection

开发者 https://www.devze.com 2023-01-27 23:58 出处:网络
I have a question regarding htaccess redirecting. I have a domain called www.test.com and there are so many subfolders in that, like www.test.com/admin/, www.test.com/users/ etc. I开发者_Go百科 just

I have a question regarding htaccess redirecting.

I have a domain called www.test.com and there are so many subfolders in that, like www.test.com/admin/ , www.test.com/users/ etc. I开发者_Go百科 just want to redirect to different URLS based on each URL, i.e,

www.test.com  should redirect to www.abc.com
www.test.com/admin/  should redirect to www.xyz.com
www.test.com/users/  should redirect to www.pqr.com

How can I write an htaccess file to redirect to different URLs based on each request (something like checking condition in the incoming URL)?


You want something like:

RewriteEngine on
RewriteRule ^users/(.*)$ http://www.pqr.com/$1 [L,NC,QSA,R=301]
RewriteRule ^admin/(.*)$ http://www.xyz.com/$1 [L,NC,QSA,R=301]
# ... add more rules as needed
RewriteRule ^(.*)$ http://www.abc.com/$1 [L,NC,QSA,R=301]
0

精彩评论

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