I need to use .htaccess to permanently redirect domain.com/folder to folder.domain.com
I also need to convert domain.com/folder and folder.domain.com/folder2 to folder.domain.com/index.php?source=folder2
index.php being hidden... so it ends up as folder.domain.com/?source=folder2
This needs to work whether or not there is a trailing slash
The ?source=folder2 needs to actually work as a query string for $_GET
Asked
Active
Viewed 238 times
0
1 Answers
0
Try adding this to the domain.com
document root's htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^folder(.*)$ http://folder.domain.com/$1 [L,R=301]
And in the htaccess file for folder.domain.com
(of if it's the same, just append it):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^folder\.domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ /index.php?source=$1 [L]

Jon Lin
- 142,182
- 29
- 220
- 220
-
This did not work... it redirected several times through several other websites and ended up trying to download a file from the last site. – AssociatedVOIP.com Aug 06 '13 at 15:16