We've been racking our heads trying to figure out what the syntax should be for this ReWrite Rule... Here's what we are trying to do. - We have a secured domain - it's called "https://ssl.mydomain.com" - All the code for the domain is in the directory "f:/webstuff/code" - There are additional folders beneath the 'code' folder (up to 5 levels deep) So far, pretty simple... - We are setting up clients with their own login in name, i.e. client1, client2, client3, etc. - We would like to trap the clients name within the URL, however, we still want to redirect them to the main directory "F:/webstuff/code" - Basically, the URL would look something like this for the above clients. "https://ssl.mydomain.com/client1/index.php" "https://ssl.mydomain.com/client2/index.php" "https://ssl.mydomain.com/clientN/index.php" - Obviously, we don't want to create a 'clientN' folder for each client. - We just want to redirect them back to the main folder. Here's what we have in the ssl.conf file. (we are running Apache 2.0.37) RewriteEngine On RewriteRule (.*)/(.*) f:/webstuff/code/$2 The problem with this code is that any attempt to get past the 'code' folder results in an error 404. So, "https://ssl.mydomain.com/client1/index.php" works...but, "https://ssl.mydomain.com/client1/test/index.php" does not work... I'm sure this is pretty simple...but we are new at this... Thanks in advance to anyone who can help. Ed
Your regex matches: anything/anything If you've got more than one /, you can split it up in more ways than one. client1/test/index.php client1/test/index.php Red/black denotes $1 and $2. With the regex you've used, either way will fit the pattern. I assume that by default, it's going for the first option and that's not what you want. You want it to only 'remove' the first directory. Directories are separated by / so we can use a regex pattern that matches everything other than a /, and then the .* to match the rest of the url. RewriteRule ^([^/]+)/(.*)$ f:/webstuff/code/$2
Thanks for your quick response... I put that code in our SSL.CONF file and it didn't help...theoretically, shouldn't these URLS be equivelent? http://ssl.mydomain.com/_templates/natural/images/skin1/logo.gif https://ssl.shoprw.com/client1/_templates/natural/images/skin1/logo.gif The first URL works fine, the second one results in an error 404...
Sorry...the second URL should be... https://ssl.mydomain.com/client1/_templates/natural/images/skin1/logo.gif