[SOLVED] - pages do not redirect

Discuss practical ways rearrange URLs using mod_rewrite.

[SOLVED] - pages do not redirect

Postby swapdude » Mon Apr 28, 2008 2:22 pm

Hi,

My old web company set up pages like

http://www.domain.com/?pg=about
http://www.domain.com/?pg=contact

etc

he then used php includes to display the data. it is not at all efficient.

Now i have created pages like

http://www.domain.com/about/
http://www.domain.com/contact/

But this is not working at all

i tried

redirect 301 /?pg=about http://www.domain.com/about/
redirect 301 ?pg=about http://www.domain.com/about/

but they don't work.

any help appreciated
Last edited by swapdude on Tue Apr 29, 2008 10:56 am, edited 1 time in total.
swapdude
 
Posts: 8
Joined: Sat Mar 08, 2008 9:26 pm

Postby richardk » Tue Apr 29, 2008 10:22 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?pg=(about|contact)(&.*)?$ [NC]
RewriteRule ^$ /%2/? [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby swapdude » Tue Apr 29, 2008 10:24 am

hi richardk

thanks for the response.

lets say i have a page

?pg=page1 but i need to redirect it to /capabilities/

how would i do that ?
swapdude
 
Posts: 8
Joined: Sat Mar 08, 2008 9:26 pm

Postby richardk » Tue Apr 29, 2008 10:55 am

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?pg=page1(&.*)?$ [NC]
RewriteRule ^$ /capabilities/? [R=301,L]

RewriteCond %{QUERY_STRING} ^(.*&)?pg=(about|contact)(&.*)?$ [NC]
RewriteRule ^$ /%2/? [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby swapdude » Tue Apr 29, 2008 10:56 am

Thanks richardk ! ! ! !

You Rock !
swapdude
 
Posts: 8
Joined: Sat Mar 08, 2008 9:26 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 110 guests

cron