Forum Moderators: phranque
My htaccess code is:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/page.php?url=$1 [L]
Thanks
[edited by: jdMorgan at 7:43 pm (utc) on May 30, 2008]
[edit reason] example.com [/edit]
RewriteEngine on
#
# Externally redirect to canonical domain
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
# Internally rewrite friendly URLs to page.php script
RewriteCond $1 !^page\.php$
RewriteRule (.*) /page.php?url=$1 [L]
You may or may not wish to use the first rule at all -- Because you've mixed the two functions, I can't tell. The second rule will only work if your subdomains are in the same filespace on the same server as the files for yoour main domain. If they are on a different server or in a separate filespace, then there is no way to do an internal rewrite, and you'll either have to proxy the requests over, or use a redirect as you have done (which always changes the address bar).
Jim