Reply
URL validation with .htaccess?
Old 09-04-2007, 05:02 PM URL validation with .htaccess?
Junior Talker

Posts: 2
Hi everyone at webmaster-talk. This is my first post. Here is my dilema.
I am currently working to bring my websites non-production server into PCI compliance. I have resolved all issues and vulnerabilities i got from hacker safe save for this one:
try entering this into your address bar:
http://64.57.246.177/x%27%3B%22%2C%2...0-00548-00.htm
this will throw a MySQL error. Whats the problem with that you ask?
Well there is no folder on my site named: x%27%3B%22%2C%29%60 or its unencoded equivalent: x';",)`
Thus what it should be throwing is the 404 not found error.
Based on this I have to find a way to validate the URL on the server side before any pages whatsoever are loaded. (adding a redirect to the garmin_dogtracking_astro_etc...htm page is out as this is one of about 1000 product pages.
I think this could be done using maybe the <Location> directive in the .htaccess file or maybe mod_rewrite, although that is about as far as i got before i got completely lost in the Apache manual.
Basically I'm looking for a way to validate the URL before any pages have been loaded. Lemme know what you all think and happy tuesday.
01true is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 09-05-2007, 03:49 PM Re: URL validation with .htaccess?
chrishirst's Avatar
Super Moderator

Posts: 16,452
Location: Blackpool. UK
What HTTP response does the URL return (without the redirect of course)?

Is there any URL rewriting in place already?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System | Bits & Bobs
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-05-2007, 04:00 PM Re: URL validation with .htaccess?
Junior Talker

Posts: 2
Thank you for your interest chrishirst, I have actually just found the answer to this one in the last half hour so I will post it now.

I added the following to my root level .htaccess file:

# Redirect any bad urls to fixed pages.
RewriteCond %{THE_REQUEST} x%27%3B%22%2C%29%60
RewriteRule ^(.*)/(.*)$ http://64.57.246.177/$2? [R=301,L]


Basically all this redirect does is searches for the bad string that was found in the original URL and cuts it out, it is specific to that bad string and will not work with any other bad strings, nor does it search the site to see if the content is actually there. The reason It had to be this way is somehow i was throwing mysql errors even though the path it was requesting shouldn't have existed. Hope this will help somebody. As far as me helping anyone else to use the mod_rewrite directive, I'm probably not much help as these two lines of code took me two days to get right. But I will keep an eye out for other mod_rewrite and .htaccess questions as I have at least a little better understanding of them now.
Thank you again for your interest, I'll continue blogging
01true is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to URL validation with .htaccess?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11762 seconds with 12 queries