I am attempting to implement Permalinks into my cms and that i appear to become stuck at an issue with mod_rewrite. I've got a PHP file (single.php) that will display just one publish in line with the Permalink title that will get passed right through to it. i.e. post.php?permalink=name-of-post-here.

Listed here are the guidelines I have setup:

RewriteRule ^([0-9]{4})/([a-z]+)?$ $1/ [R]
RewriteRule ^([0-9]{4})/([a-z]+)?$ post.php?permalink=$1

Also, how do you obtain the date/year (i.e. 2012), and assign that like a parameter for that PHP file. (i.e. post.php?year=2012?permalink=name-of-post-here) &lifier can all this be achieved using mod_rewrite?

Thank You.

Wish to change




You need to use this code:

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule ^([0-9]{4})/(.*)$ post.php?year=$1&permalink=$2 [L,R,NC,QSA]

If you do not want exterior redirect (change URL in browser) then remove R flag.