After facing many problems with the htaccess rewrite rule as it is at the moment I have decided to change it to something more basic but I cannot get the end page to pick up the ID.
My .htaccess is:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /article\.php\?issue=(.*)&edition=(.*)&id=(.*)&title=(.*)\ HTTP
RewriteRule ^ /article/%2/%3/%4/%5\? [R=302,L]
RewriteRule ^article/(.*)/(.*)/(.*)/(.*)$ /article.php?issue=$1&edition=$2&id=$3&title=$4 [L]
How do I get the article page to pick up the ID number?
You can use this code:
Use of
-MultiViews
is very important here. OptionMultiViews
is used byApache's content negotiation module
that runs beforemod_rewrite
and and makes Apache server match extensions of files. So/file
can be in URL but it will serve/file.php
.you can use this site
http://www.generateit.net/mod-rewrite/index.php
The following should work:
It should change
http://website.local.co.uk/article.php?issue=1&edition=leeds&id=1392214680-926677045&title=dearly-noted-presents---lace-and-leather
to
http://website.local.co.uk/article/1/leeds/1392214680-926677045/dearly-noted-presents---lace-and-leather
EDIT:
You can change
R=302
toR=301
when you are sure the redirect works correctly.