Clean URLs and Getting Section Name

I'm cleaning up my URLs and running into an issue with getting the section/sports name (e.g. football) to use to determine which section of the navigation to highlight/display.

Example URL:


Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?sports=$1 [NC,L]

So far, so good. Then I attempt to grab the section name, but it's not working:

$parsed_url = parse_url($url);
parse_str($parsed_url['query'], $output); // $output['sports'];

Is this because I need to grab the URL that is visible in the address bar?

If so, can someone explain the order that things are processed (e.g. .htaccess, php, etc.)?


You can just read the query parameters through the $_GET global array. So in your case you can just access it as follows:

echo $_GET['sports'];

Regarding the order of accessing files. First of all Apache will receive a request to a resource in a public directory, the directory contains .htaccess, this file contains instructions for Apache to handle the request for files in that directory.

After that, Apache will find the file is PHP file so it hand it over to PHP to process, the output of the script is included in the Response served by Apache.

Need Your Help

Insert ONLY TWO BUTTONS of Xib with NSBundle. Still show TableView

objective-c xcode sdk xib

Im using a .xib file to add two buttons above my table view that edit and add to the tableView. The table View Was visible before the .xib was implanted but now I cant see the table. I have set the

angular-bootstrap add new directive dosn't work

javascript angularjs angular-bootstrap

I want to create a new directive into ui.boostrap.accordion module to avoid accordion open click event.