Help with mod_rewrite

Discuss practical ways rearrange URLs using mod_rewrite.

Help with mod_rewrite

Postby alienpham » Sun Aug 10, 2008 11:25 pm

Hi everybody,

Can someone help me a problem with rewriterule, please ?
1>I have a link as below:
www.domainname.com/aidmakerdownload?cou ... =67&os=win
2>I want to rewrite it to:
www.domainname.com/aidmaker/extens/inde ... =67&os=win

Thanks
alienpham
 
Posts: 3
Joined: Sun Aug 10, 2008 11:13 pm
Location: Viet Nam

Postby Quasiuna » Tue Aug 12, 2008 9:53 am

You should try something like:

Code: Select all
RewriteRule ^aidmakerdownload?country=(.*)&organisation=(.*)&campaign=(.*)&os=(.*)$
aidmaker/extens/index.php?action=download&country=$1&organisation=$2&campaign=$3&os=$4 [R=301,L]
Quasiuna
 
Posts: 3
Joined: Tue Aug 12, 2008 9:35 am

Postby alienpham » Tue Aug 12, 2008 5:40 pm

Thank for your help. ;)

I have tried to get a result as the same your way before, but it has failed.
And i found out a solution for this problem:

Code: Select all

RewriteCond %{QUERY_STRING} ^country=([0-9]+)&organisation=([0-9]+)&campaign=([0-9]+)&os=([a-zA-Z]+)$
RewriteRule ^aidmakerdownload/$ aidmaker/extens/index.php?action=download&country=%1&organisation=%2&campaign=%3&os=%4 [L]

alienpham
 
Posts: 3
Joined: Sun Aug 10, 2008 11:13 pm
Location: Viet Nam

Postby richardk » Wed Aug 13, 2008 12:35 pm

If the variables don't change you can use the QSA (Query String Append) flag to pass them on
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^aidmakerdownload/?$ /aidmaker/extens/index.php?action=download [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby alienpham » Sat Aug 16, 2008 12:39 am

Thanks ;)
alienpham
 
Posts: 3
Joined: Sun Aug 10, 2008 11:13 pm
Location: Viet Nam


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 14 guests

cron