Mobile app version of vmapp.org
Login or Join
Sarah324

: How do I create flat link URL with .htaccess I am relatively new to URL rewriting. I recently created a forum and wishes to rewrite some of the thread URLs. I want to internally rewrite

@Sarah324

Posted in: #Htaccess #Php #Url

I am relatively new to URL rewriting. I recently created a forum and wishes to rewrite some of the thread URLs.

I want to internally rewrite this link
example.com/306/slug-title/6 (on client side)

to this link
example.com/topic?id=306&slug=slug-title&page=6
(on server side)

I also want users who enter just only the topic ID without the slug title to be redirected (301: with their URL bar changed ) to the correct link where the slug title is included. For instance

A user who enters this link
example.com/306/6
should be 301 redirected to this link
example.com/306/slug-title/6
Which will then be internally re-written on the server side to this
example.com/topic?id=306&slug=slug-title&page=6
Please how do I go about this using URL rewriting.

NOTE: The behavior I want to achieve is exactly being exhibited by the link to this question

webmasters.stackexchange.com/questions/106294/how-do-i-create-flat-link-url-with-htaccess

Remove the slug title

webmasters.stackexchange.com/questions/106294

hit Go on your browser and you get sent back to the correct link

webmasters.stackexchange.com/questions/106294/how-do-i-create-flat-link-url-with-htaccess

Although I have little knowledge of Regex, but a step by step guide will be highly appreciated.

Thanks.

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Sarah324

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme