Lubos Rendek

The only solution is determination.

301 Moved Permanently - PHP Code to Permanent Redirect

| Comments

In order to permanently redirect website to another URL we can use PHP code. To do this simple task place an index.php ( make sure that you do not overwrite your current index.php ) file into a root directory of your website. The following code will redirect any traffic to your main page to https://jobs.linuxcareers.com .

1
2
3
4
<?php
 header("HTTP/1.1 301 Moved Permanently");
 header("Location: https://jobs.linuxcareers.com/");
?>

Save the above into index.php within your site’s root directory. NOTE: The above code will not redirect traffic coming to other URLs than your main page. URLs like: http://example.com/some-other-page/ will not be redirected. For this it is better to use Apache’s .htaccess file like:

1
2
RewriteEngine On
RewriteRule ^.*$ https://jobs.linuxcareers.com [L]

or even better is to add these lines to apache’s virtual host definition file to save some runtime.

Comments