How to Use .htaccess to Create Search Engine Friendly URLs

By eHow Internet Editor

Rate: (1 Ratings)

In this article, we will look at how you can use .htaccess to create search-engine-friendly URLs. We will use .htaccess to preserve your search engine rankings when moving your site to a new domain. We will also map dynamic pages to a static address, which search engines can better index.

Instructions

Difficulty: Challenging

Things You’ll Need:

  • computer

Step1
Log in to your server and change to the directory where your Apache server stores its HTML documents. This is usually called “htdocs”.
Step2
Create the file .htaccess by typing the command: “touch .htaccess”. Don’t forget the period in front of the file name.
Step3
Open the .htaccess file in your favorite text editor so that you can add new lines to the file.
Step4
To preserve search engine rankings when moving a page, add the following line to .htaccess: “redirect 301 oldpage.html http://mynewsite.com/newpage.html”. This allows you to send users navigating to “oldpage.html” to your new site.
Step5
Redirect your entire web site to a new domain name or provider by adding the following line to “.htaccess: redirect 301 / http://mynewsite.com”.
Step6
Use the rewrite-rule generator at this site to map your dynamic URLs to a static version: http://www.webmaster-toolkit.com/mod_rewrite-rewriterule-generator.shtml
Step7
Enter your dynamic URL at the above site and click “Generate RewriteRule”. The generator will create a RewriteRule and display it in your browser.
Step8
Copy and paste the RewriteRule into your .htaccess file. Your dynamic page is now “spiderable” to search engines.

Tips & Warnings

  • In order to support RewriteRules, your Apache web server must support the mod_rewrite module. This can be configured in the main Apache configuration file and can be done by your Apache administrator.
  • You can do much more with .htaccess, including adding usernames and passwords to restrict access to your pages.
  • Make sure your .htaccess file is not world-readable or world-writeable. Only your user account should be able to edit the .htaccess file.
  • Many Apache installations allow users to browse directory indexes, enabling surfers to view all files in your directories. This can be a security problem. Prevent this by adding this line to your .htaccess file: IndexIgnore *

Post a Comment

POST A COMMENT

Request a New How-To Article

Looking for more How To information? Chances are there’s an eHow member who knows how to do what you’re looking to do. Submit an article request now!

eHow Article:  How to Use .htaccess to Create Search Engine Friendly URLs

eHow Internet Editor

eHow Internet Editor

Category: Internet

Articles: See my other articles

Related Ads

Internet

Veesites
Meet Virginia DeBolt eHow’s Internet Expert.