Ayaz Malik
Ayaz Malik

Reputation: 259

Redirecting entire subdomain to a subdirectory

I have this area inside my website http://www.designzzz.com/photography/ which was setuped as a subdomain : http://photography.designzzz.com/ . but due to some reason i had to make changes to switch it back and put a 301 redirect in the htaccess. so who ever accesses http://photography.designzzz.com/ will automatically be redirected to http://www.designzzz.com/photography/ .
But what's happening is it is only redirecting the home page , not the entire site urls.
For Example : http://photography.designzzz.com/the-happy-mantis/ should redirect to http://www.designzzz.com/photography/the-happy-mantis/
I used this code in the htaccess :

RewriteCond %{HTTP_HOST} ^photography\.designzzz\.com
RewriteRule ^(.*)$ http://www.designzzz.com/photography/$1 [R=301]

Help is appreciated and thanks in advance :}
cheers

Ayaz

Upvotes: 1

Views: 1848

Answers (1)

Oussama Jilal
Oussama Jilal

Reputation: 7739

You code looks fine, try to add the L flag so that you stop any other rule comming next from beeing executed and make sure that these lines come before any other rewrite rule

RewriteCond %{HTTP_HOST} ^photography\.designzzz\.com$
RewriteRule ^(.*)$ http://www.designzzz.com/photography/$1 [L,R=301]

Upvotes: 1

Related Questions