.htaccess

If you have a collection of rewrites and redirects to implement, you are better off using directives all from the same Apache module so that you can control the order in which they are parsed. Using RewriteCond and RewriteRule often allows greater flexibility of implementation, and of course does allow both redrects and rewrites to be implemented together.

You don't want to expose the workings of internal rewrites by having them run before any associated redirects. That can occur if they are coded using directives from different modules.

Domain canonicalisation is the first step. You also need to ensure that all internal links point to the correct version too. Visiitors browsing the site should not pass through any redirects when clicking internal navigation links.

Once you get started, you'll see many other uses for these directives and their close relatives.

One word of warning when uploading the .htaccess file. Most FTP programs hide filenames that begin with a dot. Make sure you edit that option, so you can see if there is a .htaccess file on the server already. If there is, then download that and edit it. Don't just overwrite the existing file, as you will lose all the settings that were already contained within it.

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <h1> <h2> <h3> <h4> <blockquote> <img>
  • Lines and paragraphs break automatically.

More information about formatting options