php - how to redirect a URL according to get variables in URL -
i trying change website url according variables can increase security of website.
for example want change address, htaccess file:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /category.php?cat_id=$1&mode=full&start=$1
and website url is:
http://joinexam.in/category.php?cat_id=17&mode=full&start=36
i want convert url to:
http://joinexam.in/category/1736
- where cat_id = 17
- and start= 36
so become 1736
after category.php
page, trying using .htaccess file.
here want take both cat_id
, start
variable, according these variables, want change url of website.
can explain correct way achieve this?
.htaccess
this forwards every url index.php.
options +followsymlinks rewriteengine on rewritecond %{script_filename} !-d rewritecond %{script_filename} !-f rewriterule ^.*$ ./index.php
php
get "original" url inside index.php:
// gives full url $request_uri = $_server['request_uri']; // split path '/' $params = split("/", $request_uri);
then might route based on these $params. , fast router lib suggest: https://github.com/nikic/fastroute using this, don't have mess around htaccess regexp stuff , can keep things @ php level :)
Comments
Post a Comment