阿帕奇/ mod_rewrite的/周期与格局搞乱格局、周期、阿帕奇、mod_rewrite

2023-09-02 11:42:28 作者:谈情不如逗狗

第一个问题,在这里不用什么...

First question, here goes nothing...

我想要一个新的条目翻译这个网址的希望添加到我的.htaccess文件(Apache服务器):

I'm trying to add a new entry to my .htaccess file (Apache server) with the hopes of translating this URL:

http://platform.localhost/category.all

到这个网址:

into this URL:

http://platform.localhost/index.php?page=category.all

这是我目前使用的重写规则是这样的:

The RewriteRule that I'm currently using is this:

RewriteRule ^([^/.]+)/?$ index.php?page=$1

此规则已高达正常工作,对所有URL到现在为止,我只能认为它是打破它的期限。

This rule has worked fine for all URLs up until now, I can only assume that it is the period that is breaking it.

我试图做到的,是有什么在URL后。HTTP://platform.localhost/传递到index.php的页面变量

What I'm trying to achieve is having anything in the URL after the "http://platform.localhost/" passed into the "page" variable of index.php.

我知道,我已经错过了一些愚蠢的事,可有人请仁慈地指出来?

I know I've missed something stupid, can someone please be kind enough to point it out?

干杯

推荐答案

模式表示拒绝点,但你可以做TIS:

the pattern says to reject dots, but you could do tis:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]