You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Stefan Antonelli <st...@operun.de> on 2006/12/28 15:35:17 UTC
[users@httpd] Redirect URLs using mod_rewrite
Hi there,
i would like to use apaches mod_rewrite to redirect some URLs to its new
Location. I have to change this:
http://www.doamin.de/subdir/foo.php?id=1234
into this:
http://www.domain.de/subdir/bar.php?newid=1234#sameid1234
I've tried out this and a lot of variants but none of them worked for me:
RewriteRule ^/subdir/foo.php\?id=(.*) /subdir/bar.php?newid=$1#sameid$1 [R]
Any suggestions for me?
Thanks for Help!
Stefan.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Re: Redirect URLs using mod_rewrite
Posted by Bob <bo...@googlemail.com>.
Stefan Antonelli wrote:
> Eric Covener <covener <at> gmail.com> writes:
>> You can't match the query string in RewriteRule. Add a RewriteCond
>> that looks at %{QUERY_STRING} and use a backreference to the
>> RewriteCond match
>
> Do you have any Example where i can find this in action?
In which context are you using the rewrite rules? In directory or server
context?
per server context:
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^/subdir/foo\.php$ /subdir/bar.php?newid=%1#sameid%1 [R=301,L]
--
Bob
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
[users@httpd] Re: Redirect URLs using mod_rewrite
Posted by Stefan Antonelli <st...@operun.de>.
Eric Covener <covener <at> gmail.com> writes:
> You can't match the query string in RewriteRule. Add a RewriteCond
> that looks at %{QUERY_STRING} and use a backreference to the
> RewriteCond match
Do you have any Example where i can find this in action? Sorry but I am not
familiar with all the mod_rewrite-Stuff...
Stefan.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Redirect URLs using mod_rewrite
Posted by Eric Covener <co...@gmail.com>.
On 12/28/06, Stefan Antonelli <st...@operun.de> wrote:
>
> I've tried out this and a lot of variants but none of them worked for me:
>
> RewriteRule ^/subdir/foo.php\?id=(.*) /subdir/bar.php?newid=$1#sameid$1 [R]
You can't match the query string in RewriteRule. Add a RewriteCond
that looks at %{QUERY_STRING} and use a backreference to the
RewriteCond match
--
Eric Covener
covener@gmail.com
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Redirect URLs using mod_rewrite
Posted by David Blanco <da...@publicinet.net>.
Hi!
Stefan Antonelli escribió:
> i would like to use apaches mod_rewrite to redirect some URLs to its new
> Location. I have to change this:
>
> http://www.doamin.de/subdir/foo.php?id=1234
>
> into this:
>
> http://www.domain.de/subdir/bar.php?newid=1234#sameid1234
>
> I've tried out this and a lot of variants but none of them worked for me:
Are you sure that mod_rewrite is working (RewriteEngine On)?
> RewriteRule ^/subdir/foo.php\?id=(.*) /subdir/bar.php?newid=$1#sameid$1 [R]
>
> Any suggestions for me?
Take a look at the RewriteBase directive in the mod_rewrite docs
Try something like this:
> RewriteBase /subdir
> RewriteRule foo\.php\?id=([0-9]+)$ bar.php?newid=$1#sameid$1
Hope this helps...
Greetings
--
David Blanco - Programación y sistemas
Publicinet (Publicidad-Cine-Internet, S.L.)
Urzaiz, 71, entlo, izda. -- 36204 Vigo
Telf 902.014.606 -- http://www.publicinet.net
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org