Parsing GET values

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
smriyaz
New Member
New Member
Posts: 7
Joined: Thu Oct 09, 2008 9:43 am

Parsing GET values

Post by smriyaz »

Hi everyone,

I am using htaccess to rewrite the standard index.php + page_number url as directory/filename.

With this in mind, how do I then parse additional _GET values?

For example,
mysite.com/directory/title?additional_info=something
In this example, directory/title is a rewritten _GET value, so how do I get a hold of additional_info?

Thanks for your help and apologies if this is difficult to understand
User avatar
plger
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 15, 2008 10:38 am

Re: Parsing GET values

Post by plger »

Suppose you have the following redirection set (I know it isn't, but for the sake of the explanation this will do) ::

Code: Select all

RewriteRule ^([^/]+)/?$ index.php?page=$1 [L]
This would rewrite http://www.domain.com/somepage to /index.php?page=somepage
If you had the following url :
http://www.domain.com/somepage?var=value
It would indeed rewrite it without the get parameters.
What you could do, is change the rewrite rule to this:

Code: Select all

RewriteRule ^([^/]+)/?$ index.php?page=$1 [QSA]
QSA here means Query String Append : it means that what's after the ? will be added at the end of the rewritten url. So the output would be:
http://www.domain.com/index.php?page=somepage&var=value

Hope this helps,
Pierre-Luc
Post Reply

Return to “Developers Discussion”