hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : mod_rewrite Help Needed
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

mod_rewrite Help Needed

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 07-29-2002, 09:54 PM
loopforever loopforever is offline
Web Hosting Evangelist
 
Join Date: Jul 2002
Posts: 497
Lightbulb

mod_rewrite Help Needed


Hey all,

I need a bit of help with mod_rewrite - or anything else that will help me with this problem.

I have a problem with a specific browser, that does not urlencode its links, so if there is a space in the url, it is sent directly to apache with the space, rather than a %20. So, you're probably saying, "just use another browser, or get rid of the space before the request is sent." Unfortunately, this can't be done.

I have a patch for apache that will fix this, but I cannot apply it because I'm running Ensim on this server and I cannot recompile apache.

I want to use a mod_rewrite statement to remove the spaces from the request before it is processed by apache, my problem is that after reading everything I could find on the subject, I still don't grasp how to use it to suit my needs.

I attempted using a rewritemap to call a perl script I wrote to remove the spaces, but I get an Internal Server Error (script is properly chmodded and such).

I tried sending fake 200 headers back to the browser, no luck.

I tried using HTTP::Request and HTTP::Request::Common to send a modifed request to apache, no luck.

What I'm interested in finding out, is if anyone could help me write a rewrite statement that uses regex to remove the space without calling an external file.

If anyone could help me with this problem, I would really appreciate it. Thanks!

Reply With Quote


Sponsored Links
  #2  
Old 07-29-2002, 09:56 PM
bombino bombino is offline
Junior Guru
 
Join Date: Jun 2001
Posts: 180
Why do you need the %20's converted to spaces?

Reply With Quote
  #3  
Old 07-29-2002, 09:57 PM
loopforever loopforever is offline
Web Hosting Evangelist
 
Join Date: Jul 2002
Posts: 497
You have it backwards, I need spaces converted to %20.

Reply With Quote
Sponsored Links
  #4  
Old 07-30-2002, 01:27 AM
mwatkins mwatkins is offline
Web Hosting Master
 
Join Date: Nov 2001
Location: Vancouver
Posts: 2,416
I think you were on the right track, looking to Perl to solve this.

http://www.engelschall.com/pw/apache...teguide/#ToC44

From the guide:

Code:
RewriteEngine on
RewriteMap    quux-map       prg:/path/to/map.quux.pl
RewriteRule   ^/~quux/(.*)$  /~quux/${quux-map:$1}


and map.quux.pl is:

$| = 1;

while (<>) {
    s|^foo/|bar/|;
    print $_;
}
Instead implement a substitution routine that replaces spaces with %20.

Going to be a performance hit though. You will certainly want to incorporate a browser test (hopefully the offending browser complies with this!) so that only the offending browser causes the code to fire off... i.e.

RewriteCond %{HTTP_USER_AGENT} ^Mozilla/3.*
RewriteRule ..... your rule

__________________
“Even those who arrange and design shrubberies are under
considerable economic stress at this period in history.”

Reply With Quote
  #5  
Old 07-30-2002, 08:49 AM
loopforever loopforever is offline
Web Hosting Evangelist
 
Join Date: Jul 2002
Posts: 497
Actually, that web site is the exact place I got the idea for the rewrite map :-p.

I'm running the same exact thing, but I modifed the "replace" statement in the perl script to:

s|^ /|%20/|;

I don't even really know if this is correct - I haven't touched perl in years. I think that this would be correct also:

s/ /%20/;

No idea, I did some reading up on this subject also though. And regex: no comprende.

What I did,was point the prg: to /wsremove/wsremove.pl chmodded 755, put the rewrite code in httpd.conf and ran it. It came up with an Internal Server Error. So, I noticed there was no path to perl in the script, so I added it - still no luck.

Any ideas? Thanks!

Reply With Quote
  #6  
Old 07-30-2002, 11:35 PM
elsmore1 elsmore1 is offline
Junior Guru
 
Join Date: Nov 2000
Location: Moran, Ks
Posts: 186
Quote:
Originally posted by loopforever
Actually, that web site is the exact place I got the idea for the rewrite map :-p.

I'm running the same exact thing, but I modifed the "replace" statement in the perl script to:

s|^ /|%20/|;

I don't even really know if this is correct - I haven't touched perl in years. I think that this would be correct also:

s/ /%20/;

No idea, I did some reading up on this subject also though. And regex: no comprende.

What I did,was point the prg: to /wsremove/wsremove.pl chmodded 755, put the rewrite code in httpd.conf and ran it. It came up with an Internal Server Error. So, I noticed there was no path to perl in the script, so I added it - still no luck.

Any ideas? Thanks!
your second try was closer to what you need... that s|^ /|%20/|; line won't do what you want....

use....
s/\s/\%20/g;
to replace all spaces with %20 and make sure you are sending the relevant parts of the url to the perl script to be rewritten.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Software AG Acquires Cloud PaaS Vendor LongJump Web Hosting News 2013-04-26 12:05:25
Web Host GeekStorage Opens New Office in Oklahoma, Names Account Manager Web Hosting News 2012-07-31 14:04:33
Web Host WebHostForASP.net Launches VPS Hosting Service Web Hosting News 2012-06-29 14:52:22
Web Host VISI Provides Hosting Services to Minnesota Public Radio Web Hosting News 2011-12-30 15:45:36
Cirrus Tech Updates its VPS Hosting Offering Web Hosting News 2011-12-20 22:30:00


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?