.htaccess 友好url使用htaccess,最后一个变量也是友好url
我需要这个地址.htaccess 友好url使用htaccess,最后一个变量也是友好url,.htaccess,.htaccess,我需要这个地址 something.com/index.php?page=blog_single&id_blog=15&name=friendly-url-the-name-of-the-article 到 我尝试使用htaccess: RewriteRule ^([\w-]+)/?$ index.php?page=blog_single&id_blog=$1&name=$2 [L] 但是它并没有像预期的那样起作用,你能帮我吗?正如arkascha评论的那样
something.com/index.php?page=blog_single&id_blog=15&name=friendly-url-the-name-of-the-article
到
我尝试使用htaccess:
RewriteRule ^([\w-]+)/?$ index.php?page=blog_single&id_blog=$1&name=$2 [L]
但是它并没有像预期的那样起作用,你能帮我吗?正如arkascha评论的那样,你的2美元没有定义。我将提出两种方法:
#此处$1是文章的名称:
重写规则^([\w-]+)/?$index.php?page=blog\u single&id\u blog=15&name=1[L]
它是这样做的
something.com/friendly-url-the-name-of-the-article=>
something.com/index.php?page=blog\u single&id\u blog=15&name=friendly url文章的名称
#这里$1是id_blog,$2是友好url文章的名称:
重写规则^([0-9]+)/([\w-]+)/?$index.php?page=blog\u single&id\u blog=$1&name=$2[L]
它是这样做的
something.com/15/friendly-url-the-name-of-the-article=>
something.com/index.php?page=blog\u single&id\u blog=15&name=friendly url文章的名称
欢迎来到SO,感谢您在问题中分享您的努力。请您在问题中更清楚地提到您的友好URL示例,以便我们更容易理解我们需要如何在后端传递参数?谢谢。您要使用的URL不包含您试图分配给
ID\u blog
的ID。那么$1
的内容应该来自哪里呢?重写引擎无法神奇地猜到它。。。因此,您必须提出一个不同的URL方案,其中包含处理请求所需的所有信息。
RewriteRule ^([\w-]+)/?$ index.php?page=blog_single&id_blog=$1&name=$2 [L]
# here $1 is friendly-url-the-name-of-the-article:
RewriteRule ^([\w-]+)/?$ index.php?page=blog_single&id_blog=15&name=$1 [L]
# here $1 is id_blog, $2 is friendly-url-the-name-of-the-article:
RewriteRule ^([0-9]+)/([\w-]+)/?$ index.php?page=blog_single&id_blog=$1&name=$2 [L]