| William 2004-04-02, 2:38 pm |
| I am using the mod_rewrite for two purposes. First, to allow dynamic
mass virtual hosting via a vhost.map file (see bottom of
http://httpd.apache.org/docs-2.0/vhosts/mass.html). Secondly, I want
any requests for directory names made entirely of numbers to be
redirected to a specific php script file in my root dir.
I have it working with the code below in my httpd.conf
-----------------------------------------
RewriteEngine on
RewriteMap lowercase int:tolower
# define the map file
RewriteMap vhost txt:/Apache2/conf/vhost.map
# deal with aliases as above
RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond %{REQUEST_URI} !^/php4/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
# this does the file-based remap
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1
RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/cgi-bin/$1
RewriteCond %{REQUEST_URI} ^/([0-9]*)/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/test.php
----------------------------------------
www.mydomain.com/123/ works beautifully - it actually redirects the
request to my script "script.php" in the root and the browser address
bar still tells the user he is at www.mydomain.com/123/
www.mydomain.com/123 however posts a 404 error. I need to add to my
rewrite code in the httpd.conf something that handles such an
exception
I've tried to incorporate the example in the Apache2 URL Rewrite guide
to no avail. (http://httpd.apache.org/docs-2.0/misc/rewriteguide.html)
Any help on the matter would be greatly appreciated!
William
haunwATspcollege.edu
St. Petersburg College
|