www.webdeveloper.com
Results 1 to 2 of 2

Thread: Redirect to 'www' with current htaccess

  1. #1
    Join Date
    Sep 2011
    Location
    Bristol, England, United Kingdom
    Posts
    192

    Redirect to 'www' with current htaccess

    Hi all,

    I have this code:

    Code:
    RewriteEngine On
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteRule ^(.*)$  /index.php [NC]
    How can I also force the URL to the 'www' version? I've tried making the URL absolute, but that produces an error when I try to access pages.

    I have very limited knowledge on this.

    Thanks.

  2. #2
    Join Date
    Dec 2012
    Posts
    1

    Post

    Hello!
    Here the solution for your problem:


    Code:
    RewriteEngine on
    Options +FollowSymlinks
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^website\.com$ [NC]
    RewriteRule ^(.*)$ http://www.website.com/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$  /index.php [NC]

    Just replace "website.com" to your site adress.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles