hcse26
New Member
- Messages
- 94
- Reaction score
- 0
- Points
- 0
Redirecting with PHP
Copy the source code and edit "http://www.new-url.com" with your own url and save it as a .php file
301 Redirect with .htaccess
Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
Please REPLACE domain.com and www.newdomain.com with your actual domain name.
Live demo[my site]: http://www.craigafer14.co.uk
Notice that you got redirected to http://.craigafer14.co.uk
Hope these helped and please rep me if they did :biggrin:
PHP:
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>
Copy the source code and edit "http://www.new-url.com" with your own url and save it as a .php file
301 Redirect with .htaccess
Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
PHP:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Please REPLACE domain.com and www.newdomain.com with your actual domain name.
Live demo[my site]: http://www.craigafer14.co.uk
Notice that you got redirected to http://.craigafer14.co.uk
Hope these helped and please rep me if they did :biggrin: