Hi
I need to add the following sample url, http://www.mysite.com/home to my .htaccess file to redirect it to the following url: http://www.mynewsite.com/welcome. I've seen that my htaccess uses RewriteCond, and tried a code like this:

RewriteCond %{HTTP_HOST} ^www\.mysite\.com/home$ [NC]

RewriteCond ^(.*)$ http://www.mynewsite.com/welcome$1 [R=301,L]


However am getting Internal Server Error 500. Where did I go wrong?

RewriteCond %{HTTP_HOST} ^www\.mysite\.com/home$ [NC]

That line is for the host www.com not the uri ie:page . So if you have multiple domains on that account you might want

RewriteBase /
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteRule ^home$ http://www.mynewsite.com/welcome [R=301,L]

or every url that goes to your old site would be

RewriteBase /
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteRule ^(.*)$ http://www.mynewsite.com/welcome [R=301,L]

thanks for clearing out this issue...

I have another question on the redirection, the .htaccess is currently in my /www folder, however, am creating a new subdomain, tv.mysite.com, which must redirect again to my http://www.mynewsite.com/welcome, and the directory "tv" will be at the root of the server, how to go on with this redirection? same as before?

RewriteBase /
    RewriteCond %{HTTP_HOST} ^tv.mysite.com$
    RewriteRule ^(.*)$ http://www.mynewsite.com/welcome [R=301,L]

Yep I configured this in my htaccess, however, as I had to create a directory "tv" in my root, it is instead going there from the browser instead of redirecting to the url. Anything wrong I've done? My folder mysite.com is in fact in a hierarchy like this on the server:

root->www->sites->mysite.com, while the tv folder is root->tv

Sorry for the trouble, but its my first attempt at sub-domain creation and redirection

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.