I’m trying to implement Permalinks into my content management system and I seem to be stuck at a problem with mod_rewrite. I have a PHP file (single.php) which will display a single post based on the Permalink name that gets passed through to it. i.e. post.php?permalink=name-of-post-here.
Here are the rules I’ve set up:
RewriteRule ^([0-9]{4})/([a-z]+)?$ $1/ [R]
RewriteRule ^([0-9]{4})/([a-z]+)?$ post.php?permalink=$1
Also, how do I get the date/year (i.e. 2012), and assign that as a parameter for the PHP file. (i.e. post.php?year=2012?permalink=name-of-post-here) & can all of this be done using mod_rewrite?
Many Thanks.
Want to change
http://www.website.com/post.php?year=2012&permalink=post-name-here
to
http://www.website.com/2012/post-name-here
You should use this code:
If you don’t want external redirect (change URL in browser) then remove
Rflag.