943,740 Members | Top Members by Rank

Jul 24th, 2008
0

URL Rewriting pass query string

Expand Post »
Hi,
I have set up a URL rewriting rule for my website:
RewriteRule ^([A-Za-z]+)/([A-Za-z]+)\.html$ /main.php?Area=$1&Page=$2
Which works fine if I request a page like
http://mysite.com/folder/something.html
it would show
http://mysite.com/main.php?Area=folder&Page=something
but I want to also be able to pass the rest of the query string so something like
http://mysite.com/folder/something.html?Bob=Jim
would pass the query string onto the main.php page like
http://mysite.com/main.php?Area=fold...ething&Bob=Jim
Is there a way to do this.
Regards,
Sam Rudge
Similar Threads
Reputation Points: 26
Solved Threads: 31
Posting Whiz
samarudge is offline Offline
354 posts
since May 2008
Sep 7th, 2008
0

Re: URL Rewriting pass query string

Hi Sam,

Click to Expand / Collapse  Quote originally posted by samarudge ...
Hi,
I have set up a URL rewriting rule for my website:
RewriteRule ^([A-Za-z]+)/([A-Za-z]+)\.html$ /main.php?Area=$1&Page=$2
Which works fine if I request a page like
http://mysite.com/folder/something.html
it would show
http://mysite.com/main.php?Area=folder&Page=something
but I want to also be able to pass the rest of the query string so something like
http://mysite.com/folder/something.html?Bob=Jim
would pass the query string onto the main.php page like
http://mysite.com/main.php?Area=fold...ething&Bob=Jim
Is there a way to do this.
Try this:
RewriteRule ^([A-Za-z]+)/([A-Za-z]+)\.html$ /main.php?Area=$1&Page=$2 [PT,QSA]
Or this (the PT in the example above will make the viewer only see /some/url.html - and NOT /main.php?Area=x&Page=y - if you want the viewer to see/main.php etc remove the PT):
RewriteRule ^([A-Za-z]+)/([A-Za-z]+)\.html$ /main.php?Area=$1&Page=$2 [QSA]
You can find more information here: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

Adnan
Reputation Points: 15
Solved Threads: 1
Newbie Poster
tgbyhn is offline Offline
8 posts
since Sep 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Linux Servers and Apache Forum Timeline: Dude, I'm Wantin' a Dell
Next Thread in Linux Servers and Apache Forum Timeline: Silent Installation of ApacheDS and Directory Studio





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC