Reputation: 2504
I have various links on my site which are all generated via PHP MySQL queries. So on one page, it may give a load of results, and if click one it may take me to:
.../sector.php?county=Kent
However I have a Rewrite Rule
RewriteEngine On
RewriteRule ^county/([^/]*)\.html$ /sector.php?county=$1 [L]
But still when I click on the link, I still see the above instead of :
http://sitename.co.uk/county/Kent
Am I doing something wrong? This is the top of .htaccess file just in case it's formatted wrong, everything else works. :
RewriteEngine On
RewriteRule ^county/([^/]*)\.html$ /sector.php?county=$1 [L]
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /customers/6/c/d/sitename.co.uk/httpd.www/...
AuthGroupFile /dev/null
<Files site.php>
require valid-user
... Obviously that's not the whole thing, Just he structure.
Even if I manually directed to the new link ...county/Kent i get a 404
Upvotes: 1
Views: 160
Reputation: 2676
Mod_rewrite does not modify links that you output. It only modifies incoming requests from one url to another. How that url is interpreted is up to your application. It will be up to you to get you links output in the form of href='/county/xxx'. Only you can answer how to do this at this point because it depends on how your application is coded.
The reason you are getting a 404 when trying to go to /county/Keny is probably because you are including a .html in the match rule in your .htaccess file. Your first example rule doesn't have it but the one in your sample .htaccess file does.
Upvotes: 2