Score:0

Rewriting URLs with htaccess for multiple parameters

cn flag

I'm trying to rewrite this:

https://mywebsite.com/pages/article.html?id=1&title=Title-Goes-Here

into

https://mywebsite.com/pages/article/1/Title-Goes-Here

Using this Rewrite Rule

RewriteEngine on
RewriteRule ^article/([0-9]+)/([0-9a-zA-Z_-]+)$ article.html?id=$1&title=$2 [NC,L] 

However, when I try this code in https://htaccess.madewithlove.com/ it gives me

This rule was not met.

Also tried it on my website htaccess file with no result. I don't know where is the problem.

Score:0
cn flag

from stackoverflow

Using this in htaccess:

RewriteEngine ON
##External redirect in browser rules here....
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{THE_REQUEST} \s/([^/]*)/([^.]*)\.html\?id=([^&]*)&title=(\S+)\s [NC]
RewriteRule ^ /%1/%2/%3/%4? [R=301,L]

##Internal rewrite to html file rules here....
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$  $1/$2.html?id=$3&title=$4 [QSA,NC,L]

and this in article.html right after head opening tag

<base href="/" /> 

All is working as intended. Someone helped me with that code :)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.