Results 1 to 3 of 3

Thread: .htaccess rewrite rules for URL with or without "www"

  1. #1
    Join Date
    Jul 2005
    Location
    Sao Paulo, BRAZIL
    Posts
    3,763

    Default .htaccess rewrite rules for URL with or without "www"

    Usually I include at both ".htaccess" files (frontend and backend) rewrite rules to redirect browsers to a URL with or without "www" (I do prefer without "www") and I always had to hardcode the domain. With the below rules, there is no need to hardcode the domain so we can use it at any installation.
    This may not be "new" to you but it was to me!
    Anyway, decided to share this finding (source here).

    For Open-Realty frontend:

    Code:
    #Redirect www to non-www
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    Code:
    #Redirect non-www to www
    RewriteCond %{HTTP_HOST} !^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://www\.%{HTTP_HOST}/$1 [R=301,L]
    For Open-Realty backend:

    Code:
    #Redirect www to non-www
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://%1/admin/$1 [R=301,L]
    Code:
    #Redirect non-www to www
    RewriteCond %{HTTP_HOST} !^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://www\.%{HTTP_HOST}/admin/$1 [R=301,L]
    Eduardo

    Open-Realty® DOCs
    We can easily forgive a child who is afraid of the dark; the real tragedy of life is when men are afraid of the light. (Author Unknown)

  2. #2
    Join Date
    Jun 2005
    Posts
    90

    Default Re: .htaccess rewrite rules for URL with or without "www"

    eduardo..

    Will this work in the latest version 3.1.6..

    When not using www. in the address bar I get this message.. " We are in MAINTENANCE MODE "

    TIA.
    ελλάσρέαλτυ.gr - Advertising Greek Property Listings! with OR Version 3.1.6

  3. #3
    Join Date
    Jun 2005
    Posts
    90

    Default Re: .htaccess rewrite rules for URL with or without "www"

    It's all good with good.. Must have been a munchkin...
    ελλάσρέαλτυ.gr - Advertising Greek Property Listings! with OR Version 3.1.6

Similar Threads

  1. SOLVED:Problem with BULGARIAN(RUSSIAN) letters "И" and "ш"
    By dronerat in forum Language help, ideas, discussion & Releases (CLOSED)
    Replies: 2
    Last Post: 06-15-2010, 05:35 PM
  2. Shared hosting wont allow the "dot" in .htaccess for seo url's
    By Tree Bones in forum General Help (CLOSED)
    Replies: 3
    Last Post: 12-10-2009, 03:49 PM
  3. Slideshow addon - Changing "Play" and "Pause" buttons to diff. text.
    By Panasonick in forum Addon help, ideas and discussion (CLOSED)
    Replies: 0
    Last Post: 12-12-2008, 11:34 AM
  4. Change Main Java Rows from "click(imgchange)" to "mouseover"
    By rentapts in forum General Help (CLOSED)
    Replies: 10
    Last Post: 03-25-2008, 01:42 AM
  5. rewrite rules
    By jordi in forum Installation/Configuration Help (CLOSED)
    Replies: 1
    Last Post: 09-06-2007, 07:30 AM

Bookmarks

Posting Permissions

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