.htaccess Query

Discussion in 'Programming' started by adamjblakey, Feb 23, 2010.

  1. #1
    Hi,

    I am using the following to redirect domain.com to www.domain.com but i want to add in so that if someone goes to /index.php they also are redirected to www.domain.com

    RewriteRule ^ - [E=via:http]
    RewriteCond %{HTTPS} =on
    RewriteRule ^ - [E=via:https]
    RewriteCond %{HTTP_HOST} !^www
    RewriteRule (.*) %{ENV:via}://www.%{HTTP_HOST}/$1 [L,R=301]
    Code (markup):
    Cheers,
    Adam
     
    adamjblakey, Feb 23, 2010 IP
  2. darkblade

    darkblade Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Here it to redirect non-www to www.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]

    To remove index.php try,
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]

    Should work, but test it first, I didn't. :)
     
    darkblade, Feb 23, 2010 IP
  3. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Thanks for your reply, i have tried this but does not seem to work?
     
    adamjblakey, Feb 24, 2010 IP
  4. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    RewriteRule ^index\.php$ / [R=301,L]
    Code (markup):
     
    chadsmith, Feb 25, 2010 IP
  5. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Thank you very much :)
     
    adamjblakey, Feb 26, 2010 IP