如何使.htaccess将所有虚拟网址发送到index.php

时间:2019-03-09 10:27:50

标签: php .htaccess

我有一个网站,我想通过index.php页面处理所有虚拟URL。

例如

如果我在浏览器上写 mydomain.com/page/something mydomain.com/something mydomain.com/something/something 我只想转到index.php,文件知道该怎么做。我有条件来处理所有这些链接,但是我不知道如何使用.htaccess重写。

我只对 / page / something 网址进行了以下重写,但我认为这样做是否正确(可行,但我不知道为什么)。

RewriteRule ^page/([0-9a-z_-]+)$ index.php?page=$1 [NC,L]
RewriteRule ^page/$ /? [L,R=301]

有人知道我该怎么做吗?

0 个答案:

没有答案