Exceptions for 301 redirect

Discussion in 'Apache' started by furtll, Jul 27, 2008.

  1. #1
    I have installed 301 redirection for the entire site, to redirect pages without "www" to pages with www.

    My code in htaccess:

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


    But I need that when user visit the page domain.com/1.php and domian.com/2.php user does not redirect to www.domain.com/1.php and www.domian.com/2.php respectively, i.e. is need to create an exception for these pages. How to realize this is?

    I very much look forward to your assistance. Thank you.
     
    furtll, Jul 27, 2008 IP
  2. snvc

    snvc Peon

    Messages:
    194
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you be more clear?
     
    snvc, Aug 17, 2008 IP
  3. nimhost

    nimhost Active Member

    Messages:
    235
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #3
    use this

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

    remove the space between http:// and www and yourdomain and .com because i'm not allowed to posting it without space :(
     
    nimhost, Aug 17, 2008 IP
  4. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #4
    You can try something like this:

    
    RewriteCond %{REQUEST_URI} !^/(1|2)\.php$
    
    Code (markup):
     
    zacharooni, Aug 18, 2008 IP