Forum Moderators: phranque

Message Too Old, No Replies

Rewriting a dynamic url to a directory

         

Rational

7:49 pm on Dec 23, 2005 (gmt 0)

10+ Year Member



I'm trying to rewrite requests for the following url:

[mydomain.com...]

to this url:

[mydomain.com...]

I manage to rewrite all requests for the index.php to the directory, but when I add the "?ad=03" it stops working.

Here is the line I thought should work:

RewriteRule ^index\.php?ad=03$ s-17/ [L]

I have also tried escaping both the question mark and the equal sign without that helping.

Does anyone know how to do this?

jdMorgan

8:06 pm on Dec 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You got pretty close, but you have to handle the query string separately. Query strings are not technically part of the URI, but rather, data to be passed to the resource *at* that URI. Therefore, they are handled by separate means.

RewriteCond %{QUERY_STRING} ^ad=03$
RewriteRule ^index\.php$ /s-17/ [L]

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

Rational

8:40 pm on Dec 23, 2005 (gmt 0)

10+ Year Member



Fantastic! This worked like a dream.

Thanks a lot!