- This topic has 0 replies, 1 voice, and was last updated 6 years, 10 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
Home › Forums › Developing Websites › HTML PHP Snippets › PHP Htaccess Redirects › Redirect a subdomain to a main domain?
I went into my hosting. Clicked and the subdomains section and then redirected it to the main domain.
When I checked in the subdomain on the server it had created a .htaccess file and placed this code in it:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^forum\.tips4pc\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.forum\.tips4pc\.com$
RewriteRule ^/?$ "http\:\/\/tips4pc\.com\/forums" [R=301,L]
Unfortunately I had a problem. The permalinks had changed so I really want to redirect all urls from the subdomain to the main page. This code only redirected the main page of the subdomain to the redirect page.. It did not redirect all URLs.
I tried this php redirect.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://tips4pc.com/forums");
exit();
?>
In the subdomain folder I created a file called index.php and pasted the above code in.
That didn’t work either.
Mitz from Tips4pc