1

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?

Luke Shaheen
  • 4,262
  • 12
  • 52
  • 82
  • 1
    That URL, even including the host, is currently 92 characters. There's still a lot of room. Also, where is there a limitation of 255 characters? – deceze Mar 13 '12 at 02:41
  • Erm. Uh. For some reason I thought there was - thanks for poking that question. But for knowledge purposes, I'd still like to know if there is a hash method in .htaccess! http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url – Luke Shaheen Mar 13 '12 at 02:43
  • 1
    The limit for the hostname is 256 chars, but that combined with other parts of the URL (path, query, etc.) can be a lot larger (no more then 2000 chars to be safe). – tplaner Mar 13 '12 at 02:47
  • URLs with 255 or more characters... if you think it would help you with SEO, no it won't. – Salman A Mar 13 '12 at 06:19
  • @SalmanA Are you saying that URLs with greater than 255 characters are treated negatively by SEO? – Luke Shaheen Mar 13 '12 at 12:52

1 Answers1

-1

you can build on te Database a table where you have articles( USER ,DATE, TITLE, CONTENT) and use the htacces and article.php to get like article.php?user=doe&date=2012/03/12&title=new-articlefile