Page 1 of 1

Mod Rewrite

Posted: Mon Sep 06, 2004 2:05 pm
by leewad
Hi

Heres an easy one but just cant get my head around it

I need to rewrite the following Url:

http://domain1.com/images.php?Id=25

to

http://domain2.com/images.php?Id=25

Id not always 25 !!

Any Ideas ??

Posted: Mon Sep 06, 2004 2:37 pm
by Weirdan

Code: Select all

RewriteEngine on
RewriteRule ^/images.php?Id=(d+) http://domain2.com/images.php?Id=$1

Posted: Mon Sep 06, 2004 2:44 pm
by leewad
Thanks but that didn`t work - what is the (d+) for ?
should it not be something like

Code: Select all

RewriteRule  ^/images.php?Id=(.*)$  http://domain2/image.php?Id=$1

Posted: Mon Sep 06, 2004 2:57 pm
by Weirdan
leewad wrote:Thanks but that didn`t work - what is the (d+) for ?
I was under impression that mod_rewrite used PCRE regexps. It didn't.
leewad wrote: should it not be something like

Code: Select all

RewriteRule  ^/images.php?Id=(.*)$  http://domain2/image.php?Id=$1
Nope, it should be something like:

Code: Select all

RewriteRule  ^/images.php?Id=(ї0-9]+)$  http://domain2/image.php?Id=$1

Posted: Mon Sep 06, 2004 3:19 pm
by leewad
Nope not that either !

Any more suggestions ?

Posted: Mon Sep 06, 2004 3:20 pm
by John Cartwright
$_SERVER['QUERY_STRING'] and tell us what that returned.

Posted: Mon Sep 06, 2004 3:25 pm
by leewad
Nothing - what should it have returned ?

I have the another mod_rewrite which works fine:

Code: Select all

^newimage/(.*).jpg$ http://www.domain2/sales/$1.jpg
But cant get the other one to work

Posted: Mon Sep 06, 2004 3:47 pm
by redmonkey
Not tested but you could try....

Code: Select all

RewriteEngine on 
RewriteRule  ^images\.php\?Id=(ї0-9]+)$  http://domain2/image.php?Id=$1 їR]
or, as escaping special characters is borked on some versions.....

Code: Select all

RewriteEngine on 
RewriteRule  ^images\.php(.*)  http://domain2/image.php$1 їR]