URL Rewrite QueryString Params

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 8
Joined: 29 May 2012, 10:02

URL Rewrite QueryString Params

29 May 2012, 10:14

Hi

I'm new to this and was looking for a push in the right direction.

I have this url - PreviewGames/seo-template.aspx?type=blackjack&game=pontoon&gid=0&mid=0

Which I would like to be re-written as - PreviewGames/blackjack/pontoon/ can someone help please?

So if somebody were to use the link - PreviewGames/seo-template.aspx?type=blackjack&game=pontoon&gid=0&mid=0 they would actually see this url - PreviewGames/blackjack/pontoon/

Also, is there a way to replace %20 with _ ?

Thanks
M

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: URL Rewrite QueryString Params

29 May 2012, 10:18

Hello,

Do you actually mena that you want to REDIRECT PreviewGames/seo-template.aspx?ty...id=0 --> to --> PreviewGames/blackjack/pontoon/ and actually display the content of PreviewGames/seo-template.aspx?typ...d=0?

Regards
Andrew

User avatar
Posts: 8
Joined: 29 May 2012, 10:02

Re: URL Rewrite QueryString Params

29 May 2012, 10:24

Hi

Yes that's right. I require a dynamic solution as I have hundreds of urls. Basically

PreviewGames/seo-template.aspx?type=[GAME_TYPE]&game=[GAME_NAME]&gid=0&mid=0 would get redirected to - PreviewGames/[GAME_TYPE]/[GAME_NAME]/

Thanks
M

User avatar
Posts: 8
Joined: 29 May 2012, 10:02

Re: URL Rewrite QueryString Params

29 May 2012, 10:38

At the moment I have this code working;


<Directory ~ "F:/Websites/.*/">
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ seo-template.aspx/%{REQUEST_URI} [QSA,L]
</Directory>

If I land on the page having followed PreviewGames/Blackjack/Pontoon/ then i get to see what is on - PreviewGames/seo-template.aspx?type=blackjack&game=pontoon&gid=0&mid=0

However if I follow the link - PreviewGames/seo-template.aspx?type=blackjack&game=pontoon&gid=0&mid=0
it does not redirect.

User avatar
Posts: 8
Joined: 29 May 2012, 10:02

Re: URL Rewrite QueryString Params

29 May 2012, 12:52

Hi - I have solved my problem.

My solution is as follows;

RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} ^gametype=([^&]+)&gamename=([^&]+)$
RewriteRule ^(.*)$ %1/%2/? [NC,R=301,L]

Thanks
:)

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 16 guests