.htaccess,使所有没有.html的url都指向一些php文件,而没有.html的URL指向特定的路径


.htaccess, make all urls without .html go to some php files and the ones without .html to a specific path

我正在尝试让.htaccess文件工作,以下是我需要的

domain.com/some-slug-url should point to my_folder/display.php?page_url=$1

domain.com/some-other-url.html should point other specific rules

还有一个管理方面,所以我也需要一些类似的东西domain.com/admin-加载管理文件夹

我认为应该有像这样的条件

如果url未以.html结尾或不是admin。。则CCD_ 4问题是,我不是.htaccess文件的专家,但我尝试过这样做,但没有成功,我知道它没有那么复杂,但在某个地方我失去了它,除了/some-slug-url 之外,一切都正常

谢谢我在这上面浪费了很多时间试图让它继续下去。

rewriteengine on
#this one is for /admin
rewriterule ^admin$ /admin [l]
#this one is for pages ending with .html
rewriterule ^(.*)'.html /my_folder/display.php?page_url=$1 [l]
#this one is for pages not ending with .html, and not for /admin
rewriterule ^(.*)$ /someotherpath

请注意[l]参数的使用,该参数表示,如果该规则匹配,则htaccess将不会在任何其他条件下循环。