How to Apply 301 Redirects With Apache
Add 301 redirects to the PHP code that powers SEOmoz.org using PHP’s header function., Install., If your hosting services does not support mod_rewrite, urge your systems administrator to have it installed., Use Apache's Rewrite rule directive: In...
Step-by-Step Guide
-
Step 1: Add 301 redirects to the PHP code that powers SEOmoz.org using PHP’s header function.
This is the simplest method.
Utilizing the power of the apache module mod_rewrite, however, you can match specific patterns for entire folders and redirect them to their new URLs without having to go through every PHP script.
Pages with static HTML will mean that it is not practical to use javascript or META tags for redirection. -
Step 2: Install.
If your web server does not have mod_rewrite installed, read over the apache documentation for installing modules.
It will usually require you to recompile apache with the option –enable-module=rewrite or
--enable-module=most. , Most apache installations will have mod_rewrite installed by default.
For example, if a server is running FreeBSD, a mod_rewrite is included by default when installing from the ports collection.
Once it is installed, you can verify it is working by adding this line to your apache configuration file or your .htaccess file:
RewriteEngine On , -
Step 3: If your hosting services does not support mod_rewrite
-
Step 4: urge your systems administrator to have it installed.
-
Step 5: Use Apache's Rewrite rule directive: In your .htaccess file
-
Step 6: add a line such as ...
Detailed Guide
This is the simplest method.
Utilizing the power of the apache module mod_rewrite, however, you can match specific patterns for entire folders and redirect them to their new URLs without having to go through every PHP script.
Pages with static HTML will mean that it is not practical to use javascript or META tags for redirection.
If your web server does not have mod_rewrite installed, read over the apache documentation for installing modules.
It will usually require you to recompile apache with the option –enable-module=rewrite or
--enable-module=most. , Most apache installations will have mod_rewrite installed by default.
For example, if a server is running FreeBSD, a mod_rewrite is included by default when installing from the ports collection.
Once it is installed, you can verify it is working by adding this line to your apache configuration file or your .htaccess file:
RewriteEngine On ,
About the Author
Beverly Cook
Specializes in breaking down complex lifestyle topics into simple steps.
Rate This Guide
How helpful was this guide? Click to rate: