我正在尝试重写/测试到/test.php。如果我直接转到链接,它会给我一个有用的php页面,但是当我去/测试时它只是给出了404找不到的错误。我启用了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>
FIXED:将FollowSymLinks更改为+ FollowSymLinks
答案 0 :(得分:0)
如果您使用RewriteLogLevel
,您将看到服务器的功能。在您的情况下,您会看到applying pattern '^test' to uri '/test'
。将您的规则更新为:
RewriteRule ^/test$ /test.php [NC]