Forum Moderators: phranque
Edit: the Service and the JustAParam can be anything and there can be a lot of parameters, this was of course just an example :)
Can someone please help me with that? I promise I will learn this if we switch to Apache :)
Thanks
Lubox
This is actually a very simple rule, and I hope you'll give it a try. See the references cited in our charter [webmasterworld.com], especially the Rewriting Guide.
Based on your description, all you need to do is to detect /scripts/uwisapi.dll and replace it with /cgi-bin/uwcgi.exe
The query string will not need any extra work; It will pass through mod_rewrite unchanged unless you take steps to modify it.
Jim
RewriteRule ^/scripts/uwisapi.dll(.*)$ [ourdomain...]
It's working on my tests at least ..
Thanks
Lubox
RewriteRule ^/scripts/uwisapi.dll(.*)$ [ourdomain...]
1) I the left side of the rule, you don't need the first slash.
2) Also in the left side, you are backreferencing(surrounding with parens) when you don't need to. When you use parens, it saves the characters matched for use in the right side. You would use $1 to call it in the right side.
3) On the right side of the rule, you don't need to use an absolute URL unless you are redirecting to another domain.
So here it is after the changes:
RewriteRule ^scripts/uwisapi.dll$ /cgi-bin/uwcgi.exe [L]
Regards,
Birdman
So this should work fine:
RewriteRule ^/scripts/uwisapi.dll$ http://ourdomain/cgi-bin/uwcgi.exe [R=301,L]
You also didn't say whether you want an internal "silent" rewrite, or an external redirect. If you want an internal rewrite, use:
RewriteRule ^/scripts/uwisapi.dll$ /cgi-bin/uwcgi.exe [L]
The choice between an internal rewrite and an external redirect depends on whether you want search engines to up update links to the old URL. If so, use the external redirect.
<added>
> 1) In the left side of the rule, you don't need the first slash.
The leading slash will be required for use in httpd.conf. It is not needed if the code is used in an .htaccess context. In either case, if it's wrong, the code won't work.
</added>
Jim
[edited by: jdMorgan at 5:39 pm (utc) on Sep. 23, 2004]
However, I reinstalled Apache, and edited the httpd.conf as it was before with this rewriterule:
RewriteEngine on
RewriteRule ^/scripts/uwisapi.dll$ /cgi-bin/uwcgi.exe [L]
Now it fails. It says 404 not found, and the error.log says: "[Fri Sep 24 15:04:20 2004] [error] [client xx.xx.xx.xx] File does not exist: D:/Apache2/htdocs/cgi-bin"
Why is it trying to find it in /htdocs/cgi-bin? cgi-bin is not there. It's in D:/Apache2/cgi-bin and if I try the url which it should be rewritten to, everything is ok. I have ScriptAlias /cgi-bin/ "D:/Apache2/cgi-bin/"
Thanks
Lubox
Sorry for bumping this old thread, but it saves me some new explaining. I have not been able to fix the latest challenge with my rewrite. If I add our domain on the right side (http://ourdomain/cgi-bin/uwcgi.exe) it seems to work, but I want to rewrite both http and https and am not sure how to do this.
The log looks like this by the way:
#*$!.xx.xxx.x - - [20/okt/2004:07:56:58 +0200] [ourdomain.com/sid#23bc18][rid#28c3060/initial] (2) init rewrite engine with requested uri /scripts/uwisapi.dll
xxx.xx.xxx.x - - [20/okt/2004:07:56:58 +0200] [ourdomain.com/sid#23bc18][rid#28c3060/initial] (3) applying pattern '^/scripts/uwisapi.dll$' to uri '/scripts/uwisapi.dll'
xxx.xx.xxx.x - - [20/okt/2004:07:56:58 +0200] [ourdomain.com/sid#23bc18][rid#28c3060/initial] (2) rewrite /scripts/uwisapi.dll -> /cgi-bin/uwcgi.exe
xxx.xx.xxx.x - - [20/okt/2004:07:56:58 +0200] [ourdomain.com/sid#23bc18][rid#28c3060/initial] (2) local path result: /cgi-bin/uwcgi.exe
xxx.xx.xxx.x - - [20/okt/2004:07:56:58 +0200] [ourdomain.com/sid#23bc18][rid#28c3060/initial] (2) prefixed with document_root to D:/Apache2/htdocs/cgi-bin/uwcgi.exe
xxx.xx.xxx.x - - [20/okt/2004:07:56:58 +0200] [ourdomain.com/sid#23bc18][rid#28c3060/initial] (1) go-ahead with D:/Apache2/htdocs/cgi-bin/uwcgi.exe [OK]
So I want to get rid of that "prefixed with document_root" I guess..
Thanks
Lubox
Hope you don't mind me talking to myself in here, but I'll try to be gentle with myself ;) (!)
I got my rewrite rule to work for http, by using [PT,L] (instead of just [L]) in the end of it. I'm not sure why it's working now, but it seems like this tells apache to remember to continue to handle the scriptalias....or something
Anyhow, the same URL with HTTPS instead of HTTP is not working (the URL is working directly, yes). Do I have to have another rewriterule for HTTPS-connections?
This is how it looks now:
RewriteRule ^/scripts/uwisapi.dll$ /cgi-bin/uwcgi.exe [PT,L]
Thanks
Lubox
For some reason, we didn't see your thread get updated and bumped to the top of the list when you posted.
You need to fix the problem with your ScriptAlias directive before proceeding. Rather than continue to put patches on top of this problem, it would be better to figure out why rewrites end up with the /cgi-bin path prepended. Nothing happens on Apache by "magic" so there is an underlying error here.
Jim
Ok, it seems I got it going now. I had to have a rewrite-rule in the virtual host for the SSL-stuff (*cough*). The PT had to be there because I was using mod_alias.
Thank you for your help with this. On Monday I will switch from IIS to Apache if the remaining tests are ok ;)
The next thing I have to figure out is how to make compatible web services for the ones I have on IIS. But that is no big deal yet...
Lubox