我将此规则添加到根web服务器上的(htaccess
)文件中,这样,如果有人试图访问(比如/web server/test
),则索引会将"测试"输入作为字符串,但它不起作用,它会一直说错误404 not found
。
我的代码如下:
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
php_flag magic_quotes_gpc off
RewriteEngine on
RewriteRule ^([^./]{3}[^.]*)$ /index.php?page=$1 [QSA,L]
这里面有什么毛病吗?
下面是我的apache2 conf文件。。。。由于我在更改设置以覆盖所有设置后出现错误500。
现在我得到错误500。。。以便我可以提供更多信息。。。下面是我的htaccess文件代码
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
php_flag magic_quotes_gpc off
RewriteEngine On
RewriteRule ^([^./]{3}[^.]*)$ /index.php?page=$1 [QSA,L]
还有我的apache2.conf文件。。。。。
<Directory />
Options FollowSymLinks
AllowOverride All
#Require all denied
Order allow,deny
Allow from all
</Directory>
<Directory /usr/share>
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
需要注意的两个关键点。
-
确保您的根目录可以被apache覆盖,请检查apache配置,通过以下方式进行正确设置:
<Directory /> Options FollowSymLinks Multiviews #AllowOverride none AllowOverride All Order allow,deny Allow from all # Require all denied </Directory>
-
检查重写规则并确保它们能够工作。在你的情况下,我测试以下规则,并在我的本地工作乐趣。
RewriteEngine On RewriteRule ^(w+)$ /index.php?page=$1 [L]
希望这能帮助到你!