Confusion error in Apache Rewrite

I am trying to convert a simple URL (below) to a blog-style URL, but am not quite sure how to do this, all my other rules work fine, but I can't seem to be one of these.

URL I want to convert: http://www.website.com/myblog.php?id=1&title=My+blog+title

URL I want it to create: http://www.website.com/1/my-blog-title

What should be the rule?

Any help was appreciated :)

+3
source share
3 answers

try it

RewriteEngine on
RewriteBase /
RewriteRule ([0-9]+)/([^.]+) myblog.php?id=$1&title=$2
+2
source

Try this in your .htaccess file:

RewriteEngine on
RewriteRule ^(\d+)/([^/]+)$ myblog.php?id=$1&title=$2

But here hyphens are not replaced by plus signs.

+2
source

.htaccess,

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /myblog.php?id=$1 [L]

( ) , . , .

+1

Source: https://habr.com/ru/post/1745303/


All Articles