Reputation: 1243
This is probably a pretty basic question for anyone familiar with mod_rewrite, but I'm not so here it is:
I am trying to redirect urls from baseurl/school/<name>
to baseurl/school/result.php?name=<name>
. My .htaccess currently looks like this:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^school/([^/]+)/?$ school/result.php?name=$1 [NC]
I make a test request to baseurl/school/aoeu
. The request is rewritten, but the result.php script reports the value of $_GET['name']
to be "result.php", not "aoeu". I tried changing the GET
variable to something other than "name" but the issue persisted.
Upvotes: 1
Views: 20
Reputation: 143906
You need to add some conditions to prevent looping. The rewrite engine continues to run the rules until the resulting URI stops changing. Try:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^school/([^/]+)/?$ school/result.php?name=$1 [NC]
Upvotes: 1