【发布时间】:2017-10-31 08:29:33
【问题描述】:
我必须将整个 Ubuntu 14 重新安装到 16.04.3 才能将 PHP 升级到 7.0。现在机器上有 Ubuntu 16,但我的网站坏了。它使用的是 Apache 和 mod_rewrite。
/etc/apache2/sites-available/000-default.conf
...
<VirtualHost *:80>
ServerName api.example.com
ServerAdmin janos@example.com
DocumentRoot /var/www/api.example.com
<Directory "/var/www/api.example.com">
Options -Indexes
</Directory>
ErrorLog ${APACHE_LOG_DIR}/api.example.com.error.log
CustomLog ${APACHE_LOG_DIR}/api.example.com.access.log combined
</VirtualHost>
...
在服务器上:
janos@example:/var/www/api.example.com$ ls -l .htaccess dir
-rw-rw-r-- 1 janos janos 65 okt 31 09:10 .htaccess
dir:
total 4
-rw-rw-r-- 1 janos janos 6 okt 31 09:09 hello.txt
janos@example:/var/www/api.example.com$ cat .htaccess
RewriteEngine On
RewriteRule "^test.txt$" "dir/hello.txt"
janos@example:/var/www/api.example.com$ sudo service apache2 restart
janos@example:/var/www/api.example.com$ sudo a2enmod rewrite
Module rewrite already enabled
在我的客户端上:
mymachine:Downloads janos$ curl -Is http://api.example.com/test.txt|grep HTTP
HTTP/1.1 404 Not Found
mymachine:Downloads janos$ curl -Is http://api.example.com/dir|grep HTTP
HTTP/1.1 301 Moved Permanently
mymachine:Downloads janos$ curl -Is http://api.example.com/dir/|grep HTTP
HTTP/1.1 403 Forbidden
mymachine:Downloads janos$ curl -Is http://api.example.com/dir/hello.txt|grep HTTP
HTTP/1.1 200 OK
mymachine:Downloads janos$
我错过了什么?
【问题讨论】:
-
janos@example:/var/www/example.hej.hu$ php -i|grep rewriteurl_rewriter.tags => a=href,area=href,frame=src,input=src,form=fakeentry => a=href,area=href,frame= src,input=src,form=fakeentry
标签: apache .htaccess ubuntu mod-rewrite