Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.