Question

I actually have PHP code for making 301 redirect on my site.Previously i done this by putting that PHP code on \public_html\site_name\index.php and that is not the same in www\site_name\index

(\public_html and \www are not same at that time).

But now these two folders(public_html and www) are showing the same content.Then now where i need to put the code?how to achieve 301 redirect using PHP when the *\public_html* and \www folders are in same.

Was it helpful?

Solution

Give this a try, put this in your htaccess in the root of your site.

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

replace example.com with your domain.

OTHER TIPS

Create a .htaccess file in each of the directories with the folowing statement

Redirect 301 / http://anyothersite.com/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top