简体   繁体   中英

htaccess to redirect from domain with sub-directory url to the same url on sub-domain

i have problem of redirecting from domain with sub-directory like

http://mydomain.com/project/01/117q803789s92d01 or
http://mydomain.com/project/08/117t803789s92d08

.. etc

to always

http://ww2.mydomain.com/project/01/117q803789s92d01 
the other link will to 
http://ww2.mydomain.com/project/08/117t803789s92d08

... etc

i tried this

RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteRule ^project\/\/?(.*)$ "http\:\/\/ww2\.mydomain\.com\/project\/$1" [R=301,L]

but for some reason its always redirect me to wrong with missing "\\" like if i try to access

http://mydomain.com/project/01/117q803789s92d01

redirect me to

http://ww2.mydomain.com/project01/117q803789s92d01

Did I miss something?!

what basically i need to just redirect from

http://mydomain.com/project/* whole url 

to

http://ww2.mydomain.com/project/* with same whole url

Thanks for help in advance.

just for information the problem is solved as the htaccess script below is the right one

RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteRule ^project\/\/?(.*)$ "http\:\/\/ww2\.mydomain\.com\/project\/$1" [R=301,L]

thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM