Forum Moderators: phranque
I want to rewrite my site urls like:
http://example.com/index.php/username
to
http://username.example.com
I have this code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
RewriteCond %1!^(www¦ftp¦mail)$ [NC]
RewriteRule ^.*$ http://example.com/index.php/%1 [R,L]
that redirect it for me but it changes the address bar in and the
url.
http://username.example.com changes to http://example.com/index.php/username
I want to know haw can I do that without changing url in the address bar.
I hope I can give my answer in this forum.
[edited by: jdMorgan at 2:43 am (utc) on Oct. 2, 2007]
[edit reason] example.com [/edit]
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index\.php/.
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com [NC]
RewriteCond %1 !^(www¦ftp¦mail)$ [NC]
RewriteRule .* /index.php/%1 [L]
Jim
[edited by: jdMorgan at 2:45 am (utc) on Oct. 2, 2007]
RewriteEngine On
RewriteCond %{REQUEST_URI}!^/index\.php/.
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
RewriteCond %1!^(www¦ftp¦mail)$ [NC]
RewriteRule ^.*$ /index.php/%1 [R,L]
but I want to do this without changing the url in the address bar!
I have this:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /sd_/
RewriteRule ^sd_/([^/]+)/(.*)$ [$1.example.com...] [R=301,L]
that keep the addressbar url without changing when we have subdirectory to subdomain redirect. but it dosent work for rewriteing the url.
If you use [R=301] you get a 301 redirect. You don't want that here either.
If you omit the [R] then you get a rewrite. With a rewrite you specify the URL in your link and the rewrite silently fetches the content from the filepath specified in the rewrite without exposing that filepath to the end user.