1

I don't know if I am approaching this correctly. Basically I have a URL

www.mydomain.com/openings.html?jobName=accounting-manager

I want the URL to be

www.mydomain.com/openings/accounting-manager.html

So, I added this to the .htaccess

RewriteRule ^openings/([^/]*).html$ /openings.html?\ jobfilename=$1 [L]

So the URL works as intended. Now, I want to read the $_GET['jobName'] on this page so that I can get print it on the page. But after the URL rewrite the $_GET variable is not present. Is there a way to accessing? Do I need to change the rewrite or should I approach this in a different way?

Thanks.

Blueboye
  • 1,374
  • 4
  • 24
  • 49
  • What is the `?\ j` escape bit for? there's no reason for that `\[space]` to be in the url, because that'd become part of the query parameter's name. e.g. you'd need to be accessing `$_GET['\\ jobfilename']`, because `\[space]` means nothing to the url system. – Marc B Oct 10 '14 at 20:16
  • So it should be? RewriteRule ^openings/([^/]*).html$ /openings.html?jobfilename=$1 [L] – Blueboye Oct 10 '14 at 20:18
  • looks better. and you can also do a `var_dump($_GET)` in your script to see ALL of the query inputs the script's receiving. – Marc B Oct 10 '14 at 20:19
  • Ok. var_dump($_GET) shows array(0) { } – Blueboye Oct 10 '14 at 20:21
  • Maybe [this](http://stackoverflow.com/questions/6768793/get-the-full-url-in-php) could help? – andy Oct 10 '14 at 20:24

2 Answers2

1

Its most probably because multiviews is enabled. Place this at top of .htaccess file.

Options -MultiViews

Also check out QSA flag for your rule.

Aurimas Ličkus
  • 9,886
  • 4
  • 24
  • 26
  • [QSA] - query string append was what I thought of too : https://wiki.apache.org/httpd/RewriteFlags/QSA – Jonathan Oct 10 '14 at 21:13
0

use this code

<?php
$url=explode("/", $_Server['request_url']);
print_r($url);
?>

you will see an array contains the url

Farhad
  • 1,873
  • 17
  • 28