Forum Moderators: phranque

Message Too Old, No Replies

Rewrite with query string

         

dadahtml

11:00 am on Apr 13, 2006 (gmt 0)

10+ Year Member



Hello, this is my first posto to WebmasterWorld. Hello to all.

I searched the forum for some hints, but I did not find the simplest question about URL rewrite with query string:

How to rewrite:

[exemple.com...] to http://www.example.com/first_article/

and

http://www.example.com/article.asp?id=2 to http://www.example.com/second_article/

Regards, Francesco.

m4tt

11:09 am on Apr 13, 2006 (gmt 0)

10+ Year Member



Hi Francesco

Welcome to webmasterworld! I too am relatively new and have had a similar problem as you, try this:

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME}!-d
RewriteCond %{SCRIPT_FILENAME}!-f
RewriteRule ^([^/]+)/article_?$ /article.asp?id=$1

dadahtml

1:34 pm on Apr 13, 2006 (gmt 0)

10+ Year Member



Thanks for your reply, I find this other solution for my problem (permanent redirect from a query string URL to a static URL):

RewriteCond %{query_string} ^id=1$
RewriteRule ^/article.asp$ http://www.example.com/first_article/? [R=301,NC,L]

RewriteCond %{query_string} ^id=2$
RewriteRule ^/article.asp$ http://www.example.com/second_article/? [R=301,NC,L]

Someone has other hints?

Regards, Francesco.