Unable to mod rewrite ?g2_page=1

Discuss practical ways rearrange URLs using mod_rewrite.

Unable to mod rewrite ?g2_page=1

Postby gonecase » Tue Sep 16, 2008 6:53 am

I use a gallery 2 script and I tried my best using help on the site to rewrite ?g2_page=1

Here is what I wanted to do:


it should redirect to www.domain.com/wallpapers/


it should redirect to www.domain.com/wallpapers/nature/

BTW, it should not redirect pages with subsequent numbers like ?g2_page=2 or ?g2_page=3 etc etc

I tried with the following -

Rewriterule ^([^/]*)/+?g2_page1$ /wallpapers/$1/$2/ [R=301,L]

Rewriterule ^([^/]*)/+([^/]*)/+?g2_page1$ /wallpapers/$1/$2/$3-$4 [R=301,L]

It fails :o where am I going wrong?
Posts: 1
Joined: Tue Sep 16, 2008 6:42 am

Postby richardk » Tue Sep 16, 2008 11:58 am

The query string is matched with %{QUERY_STRING} in a RewriteCond
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?g2_page=1(&.*)?$ [NC]
RewriteRule ^(wallpapers(/.*)?)$ /$1? [R=301,L]
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 6 guests