Link to home
Start Free TrialLog in
Avatar of matthutaff
matthutaff

asked on

RewriteRule problem adding extension

I currently have the following .htaccess file that mod.rewrites a query to something resembling a static URL:

Options +FollowSymLinks

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase   /about/campus/
RewriteRule ^([^.]+)$ profile.php?country=$1
</IfModule>

This allows for campus information about Canada to appear as /about/campus/canada, but I'd like to add the PHP extension to the back of the URL. When I place .php in the RewriteRule, however, it doesn't work unless I add [QSA] to the end, but then all PHP files in that direct redirect to profile.php.

I am a novice at mod.rewrite, any help is appreciated.
Avatar of jentulman
jentulman

This should do it

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase   /about/campus/
RewriteRule ^([^.]+)\.php$ profile.php?country=$1
</IfModule>
Avatar of matthutaff

ASKER

It should (I've tried that solution), but when I use that RewriteRule, it passes "profile" as the query string.
ASKER CERTIFIED SOLUTION
Avatar of jentulman
jentulman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ding ding ding! Works great!