301 Redirect With PHP

Hi,
You mean if you try to open the url as http://www.domainname.com/somedir/somepage.php or http://www.domainname.com/index.php then also it is redirecting to http://www.domainname.com/ .
 
Create an .htaccess file in the root folder of your site and put this code:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.
RewriteCond %1 !^www$ [NC]
RewriteRule ^(.*)$ http://www.yoursite.com%{REQUEST_URI} [R=301,L]
 
Back
Top