php到html.htaccess帮助

php到html.htaccess帮助,.htaccess,.htaccess,我在我的.htaccess文件中有以下代码,上面的重写很好。下面的一个我不知道为什么,但我不知道如何修复它 它把RewriteRule^[^/]*.html index.php?p=order&course\u id=$1[L]作为最上面的重写命令,因为它的部分比较高,我不想把它放在目录中 重新启动发动机 重写规则^[^/]+.html index.php?p=$1[L] index.php?p=about_us 重写规则^[^/]+.html index.php?p=order&course

我在我的.htaccess文件中有以下代码,上面的重写很好。下面的一个我不知道为什么,但我不知道如何修复它

它把RewriteRule^[^/]*.html index.php?p=order&course\u id=$1[L]作为最上面的重写命令,因为它的部分比较高,我不想把它放在目录中

重新启动发动机

重写规则^[^/]+.html index.php?p=$1[L]

index.php?p=about_us
重写规则^[^/]+.html index.php?p=order&course\u id=$1[L]


谢谢,

您能给出与模式块匹配的URL示例,以及您希望将其重写到的内容吗?那将非常有帮助

我注意到的一件事是,第一个regexp测试是否将模式块与a+匹配,这意味着1次或多次,第二个regexp用a*检查,这意味着0或更多,所以我认为第二个regexp永远不会被调用,尽管我对regexps很陌生,但这只是我注意到的一点

这些资源对我非常有用:


从您将要使用的URL示例来看,这应该是可行的:

# http://website.com/about_us/ rewrites to /index.php?p=about_us
RewriteRule ^([0-9a-z_-]+)/?$ index.php?p=$1 [NC,L]

# http://website.com/order/12/ rewrites to /index.php?p=order&course_id=12
RewriteRule ^order/([0-9]+)/?$ index.php?p=order&course_id=$1 [NC,L]
第二次重写可能是:

# http://website.com/order/12/ rewrites to /index.php?p=order&course_id=12
RewriteRule ^([0-9a-z_-]+)/([0-9]+)/?$ index.php?p=$1&course_id=$2 [NC,L]

取决于你的页面结构。

@GULY好的,那么你想让domain.com/about\u us变成domain.com/index.php?p=about\u us我想,但是第二个呢?我不确定我得到这个rught,因为两个规则的LHS条件是相同的^[^/]+.html?
# http://website.com/order/12/ rewrites to /index.php?p=order&course_id=12
RewriteRule ^([0-9a-z_-]+)/([0-9]+)/?$ index.php?p=$1&course_id=$2 [NC,L]