Let's start with an example:
So requested URL would be: www.domain.com/product/hdd/samsung
I want to have a rewrite rule to get index.php and save everything after www.domain.com into php varible. So, substituted page would be for example www.domain.com/index.php?query=product/hdd/samsung. But I'am unable to write correct rule.
I tried this:
RewriteRule ^/(.*)$ index.php?query=$1 [NC,L]
The code above isn't working. I want to use the query in PHP code in the index.php:
if(isset($_GET["query"] )) {
$query=$_GET["query"];
}
I find out, there is possibility to get $query via $_SERVER['QUERY_STRING']
, am I right?
For my PHP application is varibale $query critical, because it's used for loading templates.
Questions:
What solution would you recomand me? To use $_SERVER variable or mod_rewrite?
If mod_rewrite, how to write correct RewriteRule?
Thank you
No comments:
Post a Comment