Please Help me in htaccess file mod_rewrite + redirect

Discussion in 'Search Engine Optimization' started by webmaster365, Jun 8, 2010.

  1. #1
    Please Help me in htaccess file mod_rewrite + redirect
    This is my .htaccess file and working fine.
    What I want If any one try to browse the site without www , this have the capability to redirect the url with www.

    Example:- if someone try to browse with
    http://mydomain.com/theater/city/123
    then this will be redirect to
    http://www.mydomain.com/theater/city/123

    My current .htaccess file below.

    Code:
    Options +FollowSymLinks
    Options -MultiViews
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule \.(gif|jpg)$ - [F]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    
    RewriteRule ^city/(.*)/(.*)$  index.php?city=$1&page=$2 
    RewriteCond %{QUERY_STRING} !page
    RewriteRule ^city/(.*)$       index.php?city=$1 [L]
    
    
    
    RewriteRule ^cinemas/(.*)/(.*)/(.*)$    theater.php?thid=$3&cityname=$1 [L] 
    RewriteRule ^cinemas-new/(.*)/(.*)/(.*)$    theater-new.php?thid=$3&cityname=$1 [L]	
    RewriteRule ^sitemap.xml(.*)$           sitemap.php [L]
    Code (markup):
    Thanks in advance I really require this.
     
    webmaster365, Jun 8, 2010 IP
  2. asghar.paracha

    asghar.paracha Well-Known Member

    Messages:
    720
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    118
    #2
    This code should work for you
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^abc.com [NC]
    RewriteRule ^(.*)$ http://www.abc/$1 [L,R=301]
    Code (markup):
     
    asghar.paracha, Jun 8, 2010 IP
  3. webmaster365

    webmaster365 Greenhorn

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Thanks a lot for your great help
     
    webmaster365, Jun 10, 2010 IP
  4. hassan001

    hassan001 Active Member

    Messages:
    468
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    70
    #4
    Really A great Share....
     
    hassan001, Jun 26, 2010 IP