Onarcade www to non-www redirect.

Discussion in 'Apache' started by nightteacher, Dec 3, 2011.

  1. #1
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^game/([0-9]+)/.+\.html$ file.php?f=$1
    RewriteRule ^category/([0-9]+)/.+/([0-9]+)\.html$ browse.php?c=$1&p=$2
    RewriteRule ^category/([0-9]+)/.+/?$ browse.php?c=$1
    RewriteRule ^profile/([0-9]+)/.+\.html$ profile.php?u=$1
    RewriteRule ^page/([0-9]+)\.html$ page.php?p=$1
    RewriteRule ^scores/([0-9]+)/([0-9]+)\.html$ scores.php?f=$1&p=$2
    RewriteRule ^game/[0-9]+/(newscore|index)\.php$ $1.php
    RewriteRule ^game/[0-9]+/arcade/gamedata/(.*)$ arcade/gamedata/$1 [L]
    
    
    
    </IfModule>
    
    
    Code (markup):
    This is my Htaccess, I tried putting:
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^/(.*)$ http://%1/$1 [R]
    
    Code (markup):
    But didn`t work. I want if a user enter www.site.com the htaccess to redirect him to site.com


    Thanks
     
    Solved! View solution.
    nightteacher, Dec 3, 2011 IP
  2. #2
    try this:
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://%1$1 [R=301,L]
    Code (markup):
    it should work,
     
    adimsh, Dec 3, 2011 IP
    nightteacher likes this.
  3. nightteacher

    nightteacher Member

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #3
    I did it by adding that and the rewrite base, I should add it after RewriteEngine on


    Thanks
     
    nightteacher, Dec 4, 2011 IP
  4. muskoida

    muskoida Active Member

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #4
    you must creat an .htaccess - open and put this code in:

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

    then upload into your file pages
     
    muskoida, Dec 4, 2011 IP