Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.htaccess with www and without www
#1
how to change a .htaccess to working
with or without a www.
i have a page with a begin at start "www".. and i want to force web users.. to go to a page without a www. at begin.. i know that is a 301 forwarding.. but i dont know how to use it with a get simple:
this is a original file:
PHP Code:
RewriteEngine on

# Usually it RewriteBase is just '/', but 
# replace it with your subdirectory path
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d

RewriteRule 
/?([A-Za-z0-9_-]+)/?$ index.php?id=$[QSA,L

i'm was try with a:

PHP Code:
RewriteEngine On
RewriteCond 
%{HTTP_HOST} ^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L] 
but i dont know how to use it with a .htacces file in get simple. can some one help.. and help analogously how to use it from a www.mydomain.com to http://mydomain.com
user plugin: scroll to top
Reply
#2
I'm no apache expert and I deal with it only if I have to, but as far as I'm aware, this should work:
Code:
# Usually RewriteBase is just '/', but
# replace it with your subdirectory path
RewriteBase /

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L]
Reply




Users browsing this thread: 1 Guest(s)