Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 使用三个动态参数重写URL_.htaccess_Url_Rewriting - Fatal编程技术网

.htaccess 使用三个动态参数重写URL

.htaccess 使用三个动态参数重写URL,.htaccess,url,rewriting,.htaccess,Url,Rewriting,我正在我的网站上工作,其中URL类似于: http://mywebsite.com/series.php?sid=1&part=1&name=Introduction%20to%20HTML 我在htaccess中尝试了一条规则,即: RewriteRule ^([^/]+)/([^/]+)/([^\.]+)\.html$ /series.php?sid=$1&part=$2&name=$3 要以以下形式重写URL: http://mywebsite.com/

我正在我的网站上工作,其中URL类似于:

http://mywebsite.com/series.php?sid=1&part=1&name=Introduction%20to%20HTML
我在htaccess中尝试了一条规则,即:

RewriteRule ^([^/]+)/([^/]+)/([^\.]+)\.html$ /series.php?sid=$1&part=$2&name=$3
要以以下形式重写URL:

http://mywebsite.com/1/1/Introduction to html.html
不幸的是,这对我不起作用

请有人帮我解决这个问题。如果有人能让我明白它是如何工作的,我也会很高兴。 我是htaccess的新手。 在上述规则中,我可以看到三个不同的部分,如:

1st part: ^([^/]+)
2nd Part: ([^/]+)
3rd part: ([^\.]+)\.html$
这三部分用反斜杠隔开。它们是如何工作的?我如何使用相同的重写URL表单来处理3个以上的参数(比如4或5个参数)和3个以下的参数(比如2个参数)


谢谢大家!

您的规则是正确的,只需添加
L
标志以结束规则,并确保通过Apache配置启用了.htaccess和mod_rewrite

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On

RewriteRule ^([^/]+)/([^/]+)/([^\.]+)\.html$ /series.php?sid=$1&part=$2&name=$3 [L,NC,QSA]

恐怕。这对我不起作用。你能告诉我我们添加[L,NC,QSA]的目的吗?我相信QSA在某种程度上与查询字符串有关。L呢?L代表最后一条规则,NS代表无案例比较,QSA代表(现有)查询字符串追加。您只需要L标志,但正如我所写,请确保通过Apache配置启用.htaccess和mod_rewrite。如果它们已启用,请在您的问题中发布完整的.htaccess。嘿,非常感谢。我添加了[L…]我的规则,它工作得非常完美。我的缺点是,我一直在尝试,而不是现在它工作得很完美。非常感谢。