Splitting single root dir with mod_rewrite

This is a discussion on Splitting single root dir with mod_rewrite within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi Folks, I've been tasked with moving a website from a host which used two separate root directories, one ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-17-2008
Ken C
 
Posts: n/a
Default Splitting single root dir with mod_rewrite

Hi Folks,

I've been tasked with moving a website from a host which used two
separate root directories, one for http and a second one for SSL (https)
requests, to a host which has only one root directory for both. To save a
lot of work modifying the app, I'd like to simply use mod_rewrite to emulate
having separate root dirs. In addition to the split, there is an existing
requirement that requests which do not begin with www. be externally
redirected to include that sub domain.

In the webroot, I'll create two directories, "www" and "secure". Here's
my first attempt at the .htaccess file which will reside in the webroot.
Will it work or am I missing something obvious (eg a simpler, better way to
do it?). Please note that I'm intentionally trying to prevent any access at
all to the actual webroot directory on the new host.

############# begin .htaccess
RewriteEngine On

# external redirect for all hosts which do not begin with www.
RewriteCond %{SERVER_NAME} ^[^wW]
RewriteRule ^(.*)$ http://www.domainname.com/$1 [redirect=permanent]

# split single webroot into two subdirs
RewriteCond %{HTTPS} ^on$
RewriteRule ^(.*)$ /secure/$1
RewriteRule ^(.*)$ /www/$1
############# end .htaccess

Your input is appreciated. Thanks.
--

>> Ken Clarke
>> Contract Web Programmer / E-commerce Technologist
>> www.PerlProgrammer.net





 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:44 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0