vendredi 3 mai 2019

htaccess rewrite url query string with index as base

New poster to this place but long term user.

I have a site which uses index.php and then has a viewpost.php and categorypost.php.

The viewpost is for viewing the main posts and the categorypost is for viewing posts under a category such as "webdesign".

The view post slug is made up of query string such as:

viewpost.php?postType=services&postCategory=webdesign&postTitle=somepost

I then want that to rewrite to

website/services/webdesign/somepost

First question:

Is this the correct way to do this by using 3 files or am i creating more work than needed?

Second question:

If i'm on the correct or at least an ok path, how do I go about redirecting.

I have seen about 30 or so posts around this but finding it hard to get my head around it and have ended up with 500 response or just straight redirecting.

RewriteRule ^(.*)$ viewpost.php?postTag=$1&postCategory=$2&postTitle=$3 [QSA,L]

Any help is greatly appreciate




Aucun commentaire:

Enregistrer un commentaire