Rewrite subdomain to folder keeping the URL unchanged

I’m on a cheap shared hosting with Apache and I’m trying to do the following rewrite with .htaccess:

To do this I have the following .htaccess file in the root directory:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ http://domain.com/%1/$1 [L,NC,QSA]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ $1/index.php?section=$2&page=$3 [L]

And this works actually. The problem is that if I put http://digitalcameras.domain.com/nikon/123 to the web browser address string and press Enter, the string becomes like this:

http://domain.com/digitalcameras/nikon/123

(Note that the ‘digitalcameras’ moved from the beginning to the middle).

index.php placed in the /digitalcameras folder.

So the question is: can I do the same thing without changing the address in the browser?

Related:


Leave a Reply