mobik Posted February 9, 2009 Share Posted February 9, 2009 Hi, I would like to rewrite any URL requests not containing /cs/Satellite? to contain this text ie. http://localhost/shorturl -to- http://localhost/cs/Satellite?shorturl My thinking lead me to believe that a simple rule like below would do this: RewriteEngine on RewriteLog "C:\Temp\rewite.log" RewriteRule !(^cs/Satellite?*)$ cs/Satellite?$1 [L] I appear to be way off though, can anybody help please? Link to comment https://forums.phpfreaks.com/topic/144509-shorturls-cs/ Share on other sites More sharing options...
corbin Posted February 9, 2009 Share Posted February 9, 2009 RewriteCond %{REQUEST_URI} ^/cs/Satellite\?* RewriteRule (.*) /cs/Satellite?$1 Should work. By the way, it's usually a good idea to have the / on the second part of the rewrite rule. Sometimes Apache does weird things when the / isn't included. Link to comment https://forums.phpfreaks.com/topic/144509-shorturls-cs/#findComment-758540 Share on other sites More sharing options...
mobik Posted February 11, 2009 Author Share Posted February 11, 2009 Hi Corbin, thanks for the reply. I have tried the following rule: RewriteCond %{REQUEST_URI} !^/cs/Satellite\?* RewriteRule (.*) /cs/Satellite?$1 The only change being the NOT on the Condition which is allowing requests with cs/Satellite to work normally which they didn't originally. Request without cs/Satellite are not appearing to be rewritten though resulting in a 404 error. I didn't point out that /cs/ is a Tomcat servlet which is being called through proxypass. This has made me rewrite the rule to include [P] at the end. I'm now receiving this error Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /cs/Satellite. Reason: Error reading from remote server Access.log is showing 127.0.0.1 - - [11/Feb/2009:14:31:26 +0000] "GET /cs/Satellite?/cs/Satellite HTTP/1.1" 502 403 So I think close but no cigar. I am going to try some variations on the Rule but would welcome any more help with this voodoo please. Thanks Mobik Link to comment https://forums.phpfreaks.com/topic/144509-shorturls-cs/#findComment-759675 Share on other sites More sharing options...
corbin Posted February 11, 2009 Share Posted February 11, 2009 Ahhhh yeah I forgot the ! lol. Hrmmmm, is the request even getting to the second server? Link to comment https://forums.phpfreaks.com/topic/144509-shorturls-cs/#findComment-760040 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.