I've got an existing site with hard-coded URLS (ex: http://www.example.com/users/username/2012/03/12/article-title.php
). Inside that page the article_id
is hard-coded. This URL is stored in the database under article_path
field.
I want to change this so that in the future, this url is "faked" via .htaccess, but of course I also need to account for these old styles.
I was thinking something like when a user goes to http://www.example.com/users/username/2012/03/12/article-title.php
, the .htaccess would redirect internally to http://www.example.com/article.php?article_path=/users/username/2012/03/12/article-title.php
, and then article.php
would search the database for the article_path
matching, and display that article.
I realize that this could cause the URL to be > 255 characters, so I assume I should hash the URL so that it shortens it.
Can I hash something inside .htaccess? If so, how? Or am I completely off base on how I should do this?