htaccess rewrite folder with category name and post url

htaccess rewrite folder with category name and post url

You need to parse your URL after mypage.com/blog.

I assume your categories and IDs are composed with letters and digits, but you can adapt it if it is not the case.

([a-zA-Z0-9]*)/([a-zA-Z0-9]*)

First, a serie of letter and digit, then a /, then an other serie of letter and digit.

The parentheses allow you to identify each group ($1 and $2) in the rewrite rule:

RewriteEngine On
RewriteRule ([a-zA-Z0-9]*)/([a-zA-Z0-9]*) post_details.php?post_id=$2&category=$1



Share on Pinterest
Share on LinkedIn
Share on WhatsApp
Share on Telegram