Home > Back-end >  Rewrite URL in a cleaner way for blog articles
Rewrite URL in a cleaner way for blog articles

Time:04-28

This is the original URL:

www.example.com/article/index.php?p=general&t=how-cinema-changed-our-life&i=1

I would to rewrite it like this:

www.example.com/article/general/1/how-cinema-changed-our-life

Is it possible? And of course, is it SEO friendly in this way?

I think that a better solution can be:

www.example.com/general/article/how-cinema-changed-our-life

But I don't know if I can retrieve the "i" PHP variable and how to edit it.

CodePudding user response:

For this URL:

www.example.com/article/general/1/how-cinema-changed-our-life

to work, use this in .htaccess or the virtual host of your Apache conf file:

RewriteEngine on
RewriteRule ^/?article/([a-z\-] )/([0-9] )/([a-z\-] )$ /article/index.php?p=$1&i=$2&t=$3 [L]
  • Related