Need Help with .htaccess file

Discussion in 'Apache' started by goppss, Aug 28, 2010.

  1. #1
    Hi All,

    Can someone please help with the following I have in my .htaccess file? Do I have everything correct?


    RewriteEngine On

    Options -Indexes

    RewriteCond %{HTTP_USER_AGENT} libwww [NC,OR]
    RewriteCond %{QUERY_STRING} ^(.*)=http [NC]
    RewriteRule ^(.*)$ - [F,L]

    # redirect index.php to folder
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
    RewriteRule ^(.*)index\.php$ http://%{HTTP_HOST}/$1 [R=301,L]

    # redirect non-www to www
    RewriteCond %{HTTP_HOST} ^example.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.example.com$
    RewriteRule ^index\.html$ "http\:\/\/www\.example\.com" [R=301,L]

    RewriteCond %{HTTP_HOST} ^example.com$
    RewriteRule ^/?$ "http\:\/\/www\.example\.com\/" [R=301,L]
     
    goppss, Aug 28, 2010 IP
  2. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #2
    RewriteEngine On
    
    Options -Indexes
    
    RewriteCond %{HTTP_USER_AGENT} libwww [NC,OR]
    RewriteCond %{QUERY_STRING} ^(.*)=http [NC]
    RewriteRule ^(.*)$ - [F,L]
    
    # redirect index.php to folder
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
    RewriteRule ^(.*)index\.php$ http://%{HTTP_HOST}/$1 [R=301,L]
    
    # redirect non-www to www
    RewriteCond %{HTTP_HOST} !^www.example.com$
    RewriteRule ^index\.html$ "http\:\/\/www\.example\.com" [R=301,L]
    
    Code (markup):
    Assuming it does what you want then it's right.
     
    tolra, Aug 29, 2010 IP