Forum Moderators: coopster
i have a blog which splits posts up into categories. and i write certain stuff onto the page depending on which category it is.
i do this by looking at the query string on the end of the URL.
but now i have discovered the wonderful permalinks thing in wordpress, and want to use it. so all my query strings have disappeared. and they are rewritten with the .htaccess file.
so whereas it might have been
www.example.com/category.php?no=6
now it is
www.example.com/category/no/6
but now i can't grab the url. no matter what i have tried in PHP, the best i can get is category.php. i can't grab the original query string that was on the end, nor the new /no/6 bit.
so i have no easy way of php checking which category the post is in.
does anyone know how you can grab the /no/6 bit in PHP?
so although the browser address bar says
www.example.com/category/no/6
you are actually serving page:
www.example.com/category.php?no=6
so you should be able to get the '6' by requesting a querystring in the normal way eg
$value=$_GET["no"];
does anyone know how you can grab the /no/6 bit in PHP?
Dump the entire $_SERVER variable. Run this at the top of your script to see what you have available. Typically, I believe the PATHINFO is where you should always see it, but the REQUEST_URI is what I tend to use most often.
<?php
print '<pre>';
print_r($_SERVER);
print '</pre>';
exit;
?>