重写规则在.htaccess不工作重写、规则、工作、htaccess

2023-09-02 11:42:28 作者:24k纯屌

我目前在我的本地机器上,与Ubuntu的最新版本安装在运行的Apache2。

I am currently running Apache2 on my local machine, installed with the latest version of Ubuntu.

我想获得基本的URL重写使用.htaccess文件的工作。

I am trying to get basic URL rewriting working by using the .htaccess file.

该文件的http://localhost/page.php =家确实存在,而且位置/ doesnotexist /家不

The file "http://localhost/page.php?=home" does exist, and the location "/doesnotexist/home" does not.

我想有当第二请求的第一页进行加载。

I would like to have the first page be loaded when the second is requested.

我的.htaccess文件看起来是这样的:

My .htaccess file looks like this:

RewriteEngine On
RewriteRule ^/doesnotexist/(.*)$ /page.php?p=$1 

我的httpd.conf文件看起来是这样的:

My httpd.conf file looks like this:

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

<Directory /var/www>
    AllowOverride All
</Directory>

请注意,我的httpd.conf文件容貌的完全的那样,因为它是空的之前,我编辑了。

Note that my httpd.conf file looks exactly like that, as it was empty before I edited it.

这是我得到的结果是这样的:

The result that I get is this:

Not Found

The requested URL /doesnotexist/home was not found on this server.

我用Google搜索日益居住的 * 的*出这个问题,而且我从来没有得到任何比上述错误等。

I have googled the ever living ** out of this problem, and I have never gotten anything other than the error above.

如果任何人有任何想法,我会非常AP preciative。

If anyone has any ideas, I would be very appreciative.

推荐答案

有关其他人的利益,我想出了答案:

For the benefit of others, I figured out the answer:

在文件的/ etc / apache2的/站点启用/ 000默认有行:

In the file "/etc/apache2/sites-enabled/000-default" there was the line:

AllowOverride None

更改为:

AllowOverride All