Jump to content

mod_rewrite & $_GET[] issue


avvllvva

Recommended Posts

This is my url ..../product.php?id=99&title=demo

rewrited url is ....../product/id/99/title/demo

And my .htacces content is following

RewriteEngine on

RewriteRule product/id/(.*)/title/(.*) product.php?id=$1&title=$2

 

The problem is, $_GET['id'] and $_GET['title'] giving empty results...

please give me a solution , how to get the GET variable values......

 

Thnx in advance

Link to comment
https://forums.phpfreaks.com/topic/154626-mod_rewrite-_get-issue/
Share on other sites

Nah, was the right order first time. Is it even loading the php page? If you var_dump($_GET) what do you see?

 

You could try this:

Options +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^product/id/(.*)/title/(.*)$ /product.php?id=$1&title=$2 [L]

 

I've just tested on apache and that worked correctly for me.

 

http://example.org/product/id/1/title/blah

produced:

array(2) { ["id"]=>  string(1) "1" ["title"]=>  string(4) "blah" }

 

When I var_dump'd $_GET

 

Is your product page in a subdirectory? Any errors in your server logs?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.