Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2006
    Posts
    292

    .htaccess redirection

    Trying to remove the 'www' from all incoming requests (http or https)

    For example:

    If you type in http://www.domain.com it redirects you to https://domain.com

    If you type in https://www.domain.com it redirects you to https://domain.com

    Currently this is in the .htaccess:

    Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
    </IfModule>
    This is on a Centos 5.3 box

    Mod_rewrite is installed and running properly.

    Any suggestions would be greatly appreciated.

    Thanks!

  2. #2
    Try the following code :

    Code:
     RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.domain.com
    RewriteRule ^(.*) http://domain.com/$1 [R]

  3. #3
    Join Date
    Jul 2009
    Posts
    212
    Quote Originally Posted by InstaCarma_Support View Post
    Try the following code :

    Code:
     RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.domain.com
    RewriteRule ^(.*) http://domain.com/$1 [R]
    Yes.Try his.And in another way,I am sure you can do this in your cPanel,that is more easilier there.

  4. #4
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,771
    Quote Originally Posted by smrtalex View Post
    If you type in http://www.domain.com it redirects you to https://domain.com

    If you type in https://www.domain.com it redirects you to https://domain.com
    If you need everything redirected to https://domian.com, use the following rule.

    Code:
    RewriteEngine On 
    RewriteCond %{HTTPS} !^on$ [NC]
    RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

Similar Threads

  1. .htaccess - domain redirection
    By webpromo in forum Programming Discussion
    Replies: 1
    Last Post: 03-02-2007, 01:09 PM
  2. .htaccess redirection
    By RGoulding in forum Programming Discussion
    Replies: 7
    Last Post: 06-22-2005, 08:15 AM
  3. htaccess and redirection
    By 3-rx in forum Web Design and Content
    Replies: 9
    Last Post: 05-21-2005, 10:00 PM
  4. .htaccess redirection - How to?
    By webzila in forum Web Design and Content
    Replies: 2
    Last Post: 01-04-2004, 04:06 PM
  5. Need .htaccess redirection
    By Spunky in forum Hosting Security and Technology
    Replies: 6
    Last Post: 05-21-2002, 05:38 AM

Posting Permissions

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