Jump to content

hide id with mod_rewrite


raduenea

Recommended Posts

Hi.

 

I have a link like this:

index.php?page=article-title&id=12

 

article-title and id are dynamical

 

How can I show in my address bar only: http://www.website.com/article-title/ 

not http://www.website.com/article-title/12/ 

 

What I must change in htaccess for this.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/250288-hide-id-with-mod_rewrite/
Share on other sites

If you use mod-rewrite to hide the ID, it is no longer a variable - eg: you can't GET it from the URL without having it in the URL... instead, you should use a form and POST the id to the article display page.  Or just sanitize your GET variables...

This can't be done purely via .htaccess, it's not magic, if the value isn't in the URL, then you can't use it in the script. You would need to update your script to fetch information from the database using 'article-title' instead of using the id (12). Basically you change the title to be the identifier of the article. Thus obviously it would need to be unique. Given the URL you describe it would seem you are already using mod_rewrite rules, these would just need a bit of tweaking to not match the id.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.