【发布时间】:2015-06-25 15:18:21
【问题描述】:
我正在尝试将 /test 重写为 /test.php。如果我直接转到链接,它会给我有效的 php 页面,但是当我转到 /test 时,它只会给出 404 not found 错误。我已启用 mod_rewrite 并授予 /var/www 755 权限。
.htaccess
RewriteEngine On
RewriteRule ^test test.php [NC]
test.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName test.com
ServerAlias www.test.com
DocumentRoot /var/www/test.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/test.com>
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
</VirtualHost>
修复:将 FollowSymLinks 更改为 +FollowSymLinks
【问题讨论】:
标签: php apache .htaccess mod-rewrite