Forum Moderators: phranque
My doc root in httpd.conf file is is
/var/apache2/2.2/htdocs/testprod/
I have website created under
/var/apache2/2.2/htdocs/testprod/data/example.com/
I have a couple of htmls (index.html) under this dir which will be home page
Now I need this website hosted, I made the following changes
in vhost.map entry looks like this
example.com /var/apache2/2.2/htdocs/testprod/data/example.com/
Now in httpd.conf
I have made an entry like this with mo
RewriteEngine on
RewriteMap lowercase int:tolower
# define the map file
RewriteMap vhost txt:/etc/apache2/2.2/vhost.map
# deal with aliases as above
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
# this does the file-based remap
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/data/$1
However when I type the url http://example.com it fails to work as expected.
Could you please help on what is issue with my regex.
[edited by: jdMorgan at 1:52 pm (utc) on May 24, 2009]
[edit reason] example.com [/edit]
If not, try something simple like
RewriteRule ^foo\.html$ http://www.google.com/ [R=302,L] Request "foo.html" from your server, and you should land at google.
That will determine if mod_rewrite is even working.
Then try your rule, but hard-code the servernamame, and skip the RewriteMap and tolower functions.
Then use the servername variable, but without tolower.
If that works, then try the map, but without the tolower function.
Finally, test with the full-on rule after checking each 'piece' of it. (You can change the order of my suggested steps, especially if the servername is incorrectly specified as uppercase or mixed-case. The idea is simply to break down the problem into smaller steps, instead of trying to test a complex rule all-at-once.)
Also, look at the "error return" feature of RewriteMap calls: It's likely you do not need a separate step (the RewriteCond) to check the result of the map lookup, and that you'd prefer to 'do something' if the map lookup fails, rather than just letting the whole rule fail.
Jim