Page 1 of 1

mod_rewrite and sub-domains

Posted: Sat Jul 14, 2007 12:44 am
by alex.barylski
After reading up a little more I think? it's important to also note that login.php is acting as both a FORM input script as well as a login request handler - so I need to propagate POST data?

Here is the situation:

I have these files in DOCROOT:

Code: Select all

index.php
login.php
admin.php
My .htaccess looks like:

Code: Select all

RewriteEngine on
RewriteBase /

RewriteRule ^assets/ - [L]
RewriteRule ^admin.php - [L]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
Works awesome but now...

instead of users accessing login.php like:

Code: Select all

www.domain.com/login.php
I would much prefer they use:

Code: Select all

https://login.domain.com
Notice how I need login.php to be mapped to a sub-domain (or visa versa) as well as HTTPS protocol to be used.

I don't have SSL enabled yet and I will have to read up a bit more on enabling it, but can someone show me what needs to be added to either .htaccess or apache.conf (actually virtual host setup on debian).

Keeping the three files above all inside the document root as is, is absolutely required/desired - unless I have to move login to an actual directory outside of root I don't want to... :)

Cheers :)

Posted: Sat Jul 14, 2007 4:41 am
by volka
You can set up a virtual host login.domain.com that redirects all requests to the script login.php