Need htaccess redirection

风流意气都作罢 提交于 2019-12-24 17:29:14

问题


I want to redirect below urls using htaccess

http://abc.domain.com to http://www.domain.com/pos

http://xyz.domain.com/weighing-scales.php to http://www.domain.com/weighing

I tried using below directive in .htaccess file but it is not working. Kindly help

Redirect 301 http://abc.domain.com http://www.domain.com/pos
Redirect 301 http://xyz.domain.com/weighing-scales.php http://www.domain.com/weighing-scales

回答1:


You can use the following :

RewriteEngine on

#--abc.domain.com/ => domain.com/pos--# 
RewriteCond %{HTTP_HOST} ^abc\.domain\.com$ [NC]
RewriteRule ^$ http://domain.com/pos [L,R]
#--xyz.domain.com/weighing-scales\.php =>domain.com/weighing--# 
RewriteCond %{HTTP_HOST} ^xyz\.domain\.com$ [NC]
RewriteRule ^weighing-scales\.php$ http://domain.com/weighing [L,R]


来源:https://stackoverflow.com/questions/35654713/need-htaccess-redirection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!