Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Redirect Issue

  1. #1
    Regular Coder
    Join Date
    Mar 2010
    Posts
    235
    Thanks
    39
    Thanked 6 Times in 6 Posts

    Redirect Issue

    When we use the following .htaccess the site will redirect properly for a few minutes then it just stops responding. Essentially, we want to redirect non-www requests to the www handle.

    Code:
    BrowserMatchNoCase Apache-HttpClient/4.0.1 bad_bot
    Order Deny,Allow
    Deny from env=bad_bot
    
    # Don't show directory listings for URLs which map to a directory.
    Options -Indexes
    
    # Follow symbolic links in this directory.
    Options +FollowSymLinks
    
    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\.mysite\.com
    RewriteRule (.*) http://www.mysite.com/$1 [R=301,L] 
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

  • #2
    New Coder
    Join Date
    Sep 2011
    Posts
    80
    Thanks
    0
    Thanked 13 Times in 12 Posts
    Try the inverse:

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

  • Users who have thanked MarkR for this post:

    mathceleb (07-18-2012)

  • #3
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    6
    Thanks
    0
    Thanked 1 Time in 1 Post
    Below code works well for non-www to www redirects.

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    You can refer here:
    http://www.ganeshbabujayaraman.com/a...and-drupal-cms


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •