Redirecting Using .htaccess

Discussion in 'Site & Server Administration' started by Masterful, Mar 24, 2011.

  1. #1
    I want to redirect all of the non-www pages of my Web site to their www-including counterparts. I also want to redirect mydomain.com/index.php to mydomain.com. To that effect, I created a .htaccess file, added the following code to it, and uploaded it to the folder in which my Web site resides:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} mydomain\.com [NC]
    RewriteCond %{HTTP_HOST} !^www\.mydomain\.com [NC]
    RewriteRule ^(.*) http://www.mydomain\.com/$1 [L,R=301]
    
    Options +FollowSymLinks
    RewriteEngine on
    # index.php to /
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
    RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
    Code (markup):
    My question is, can you see anything wrong with what I done?

    Everything seems to be working properly, but I am still worried.

    Note that I have another .htaccess file in public_html that includes this stuff:

    order allow,deny
    deny from 66.197.185.21
    allow from all
    DirectoryIndex index.html index.wml index.cgi index.shtml index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml index.htm default.htm default.html home.htm hostgator.html
    
    AddType application/xhtml .xml
    AddHandler application/xhtml .xml
    
    <IfModule mod_suphp.c>
     suPHP_ConfigPath /home/heru
     <Files php.ini>
       order allow,deny
       deny from all
     </Files>
    </IfModule>
    Code (markup):
    Can my two .htaccess files interfere with each other?
     
    Masterful, Mar 24, 2011 IP
  2. chris-designer

    chris-designer Member

    Messages:
    150
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #2
    I think htaccess file works only in that direstory where it is created....so i assume everything is ok with your site. :)
     
    chris-designer, Mar 24, 2011 IP