Forum Moderators: phranque

Message Too Old, No Replies

rewritemap tolower interfering with DW MMHTTPDB.php?

tolower function appears to interfere with DW from connecting to mysql db

         

Delirious

11:45 am on Dec 31, 2008 (gmt 0)

10+ Year Member



My work has switched hosts, going from a coldfusion site to plain .html, with a few php pages for contact forms and such. So far I have managed to get everything redirecting properly with a series of 301 redirect/rewrite in htaccess, with the help of rewrite map tolower in our httpd.conf file.

Ever since we added the tolower code, Dreamweaver CS3 gives me the error 404 - testing service specified for this site does not map to the [localhost...] URL message. The testing server settings are correct because they worked until the tolower code was added and I havent changed any settings since then, and the php pages still work on the site, its just DW.

I'd tried the a-z 26 rule loop w/ htaccess, but it was way slower than rewrite map, and didn't quite cooperate with some of .cfm?x= rewrite rules for link on the old site.

Anyone have any ideas? either a way to force Dreamweaver to play nice with lowercase named /_mmserverscipts/mmhttpdb.php, or a way to tell rewrite map tolower to skip over /_mmServerScipts/ folder? I checked out the apache documentation, but it was too technical for me, I'm really just a photo/video/html guy in over his head - the most scripting I've had is a semester of JavaScript and the last 3 weeks straight on google for all this apache stuff lol
thanks

Caterham

12:12 pm on Dec 31, 2008 (gmt 0)

10+ Year Member



a way to tell rewrite map tolower to skip over /_mmServerScipts/ folder

Use a simple condition above your rule which checks for REQUEST_URI

RewriteCond %{REQUEST_URI} !^/_mmServerScipts/

if you'd like to skip requests starting with /_mmServerScipts/ (in that case).

Delirious

7:43 pm on Dec 31, 2008 (gmt 0)

10+ Year Member



This would go above the first Rewrite condition, like this?:

RewriteEngine On
# rewrite to force lowercase
RewriteMap lowercase int:tolower
RewriteCond %{REQUEST_URI} !^/_mmServerScripts/
RewriteCond %{HTTP_HOST} ^(www\.)?(([^.]+\.)+([^.]+))
RewriteRule ^/([^A-Z]*[A-Z].*)$ [%2...] [R=301,L]

unfortunately I don't have direct access to httpd.conf and my host has been lagging lately as they are moving offices... so it will probably be a day or two until I actually get to test it out = (

Thanks Again!

jdMorgan

8:35 pm on Dec 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That should work just fine.

You've got an opportunity to optimize the code by getting rid of an unneeded layer of parentheses/back-reference-creation, though:


RewriteCond %{HTTP_HOST} ^(www\.)?(([^.]+\.)+[b][^.]+[/b])

and you can make that RewriteCond and the rule as a whole more robust by providing for appended periods (FQDN) and port numbers:

RewriteCond %{HTTP_HOST} ^(www\.)?(([^.]+\.)+[^.]+)[b]\.?(:[0-9]+)?$[/b]

This fool-proofs the pattern against perfectly-valid but unusual requested hostnames such as "www.example.com.", "www.example.com:80", or "www.example.com.:80"

If you don't properly handle the trailing period in this "www.example.com." FQDN example, then your rule won't be invoked because your existing RewriteCond pattern demands that additional non-period characters follow that final period. As a result, it would be easy to 'create' 404's on your site by linking to the FQDN with uppercase-containing URLs.

Jim

Delirious

12:33 am on Jan 6, 2009 (gmt 0)

10+ Year Member



worked like a charm - thanks for all your help