This is a discussion on Apache2 the Trailing Slash problem within the Windows Web Servers forums, part of the Web Server and Related Forums category; I am using the mod_rewrite for two purposes. First, to allow dynamic mass virtual hosting via a vhost.map file (...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
> 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 the reason for the failure is quite obviously the fact that /123 does not match ^/([0-9]*)/ - the evident approach of ^/([0-9]*) will probably bite you when somebody has a file /123go.html, though. try the following: RewriteCond %{REQUEST_URI} ^/([0-9]*)/ [OR] RewriteCond %{REQUEST_URI} ^/([0-9]*)$ RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$ RewriteCond ${vhost:%1} ^(/.*)$ RewriteRule ^/(.*)$ %1/test.php joachim |