Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!


Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 




From the folks who brought you High Rankings!

- - - - -

Setting Up .htaccess File For Apache

  • Please log in to reply
2 replies to this topic

#1 TeamSDA


    HR 1

  • Members
  • Pip
  • 2 posts

Posted 23 March 2011 - 06:40 PM

Hi All,

Looking through apache.org and a other couple forums, Iíve put together the code that is listed below for my .htaccess file. Since Iím just a beginner at putting together an .htaccess file, can anyone see any issues with the code? Iíve listed the functions of this code below.

1. Redirects non-www. to www.

2. Redirects www.example.com/index.html to the root (www.example.com)

3. Take all 404 Errors to the custom error page

RewriteEngine on RewriteCond %{HTTP_HOST} !^www.example.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]/)index.html(\?[^\ ])?\ HTTP/ RewriteRule ^(([^/]/)*)index.html$ http://www.example.com/$1 [R=301,L]

ErrorDocument 404 /Errors/404.html

Thank you for your help,


#2 Jill


    Recovering SEO

  • Admin
  • 33,244 posts

Posted 24 March 2011 - 08:22 AM

The best way to know if it works is to simply try it. You can remove it if it breaks things.

#3 rominosj


    HR 2

  • Active Members
  • PipPip
  • 26 posts

Posted 24 March 2011 - 12:41 PM

Hi Jill,
Why reply if you don't know the answer? Isn't the idea to help?

Make sure you write each directive on a separate line:

#non-www to www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

#www.examples.com/index.html to www.examples.com
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.(htm?|php)(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]*/)*)index\.(htm?|php)$ http://www.example.com/$1 [R=301,L]

ErrorDocument 404 /Errors/404.html



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

We are now a read-only forum.
No new posts or registrations allowed.