gpt4 book ai didi

php - mod_rewrite 无法在 Ubuntu 上使用 apache2

转载 作者:行者123 更新时间:2023-12-04 19:03:27 25 4
gpt4 key购买 nike

我似乎无法让 mod_rewrite 工作,但它显示它在我执行 phpinfo() 时已启用
我的默认文件如下所示:

ServerAdmin webmaster@localhost


DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

每次尝试访问时都会出现 404 错误:
www.example.com/store 

代替:
www.example.com/store.php

知道发生了什么吗?

这是我目前的 .htaccess :
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]

最佳答案

你错过了-MultiViews , 启用它不会忽略不存在的目录。

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

## To internally redirect /anything to /anything.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

关于php - mod_rewrite 无法在 Ubuntu 上使用 apache2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22433653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com