views:

41

answers:

2

requests -----> should be written to new url

/institute/dps -----> /institute.php?slug=dps
/institute/abc -----> /institute.php?slug=abc
/institute/123 -----> /institute.php?slug=123

I am using following rule in .htaccess
RewriteRule ^institute/(.*)$ /institute.php?slug=$1

However, it's not working. the page insitute.php get's execution, but the query string always comes empty.

Any suggestions?

+1  A: 

That should work... If you try

RewriteRule ^institute/(.*)$ /institute.php?slug=$1 [R]

it should redirect formally, and you'll see the new URI

If you don't have the [R] in there it will issue the correct request, but you won't see ?slug= in the query string, but $_REQUEST['slug'] will be set.

Dorian Moore
[if you don't use [R] the redirect won't be visible, but will still be actioned]
Dorian Moore
A: 

Have you turned on Rewriting in your .htaccess file? (before your RewriteRule)

RewriteEngine On

If so - does your apache configuration allow you to use .htaccess file? (look for the line)

AllowOverride None

inside you httpd.conf it SHOULD be

AllowOverride All

Finally make sure the url rewriting module is turned on in httpd.conf (it might be commented out)

LoadModule rewrite_module modules/mod_rewrite.so

calumbrodie