wget http://maydomain.example
--2017-04-06 18:21:12-- https://mydomain.example
Resolving mydomain.example (mydomain.example)... IP
Connecting to mydomain.example (mydomain.example)|IP|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2017-04-06 18:21:12 ERROR 403: Forbidden.
但是其他域(http://OTHER.example
)正在运行,所以我将DocumentRoot
更改为OTHER并且(重启apache2后)错误是相同的!
<VirtualHost *:80>
ServerAdmin suporte@mydomain.example
ServerName mydomain.example
ServerAlias www.mydomain.example
DocumentRoot /var/www/html/OTHER.example
# DocumentRoot /var/www/html/mydomain.example
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#?? Require all granted
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.oficial.news [OR]
RewriteCond %{SERVER_NAME} =oficial.news
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>
文件/etc/apache2/sites-available/mydomain.example.conf
和/etc/apache2/sites-available/OTHER.example.conf
只能通过文件名和域名进行区分。
可能是......在父文件夹中重写或.access
?
more /var/www/html/.htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
答案 0 :(得分:2)
这是虚拟主机的配置...请参阅Rewrite*
行,我删除了全部,
# REMOVED THIS:
# RewriteEngine on
# RewriteCond %{SERVER_NAME} =www.oficial.news [OR]
# RewriteCond %{SERVER_NAME} =oficial.news
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
现在正在运作(!)。
感谢@Nomad和@MatíasNavarroCarter提供线索和清单。
答案 1 :(得分:1)
我注意到你正在使用一些Debian衍生物(可能是Ubuntu 16.04)来为你的开发环境工作。我已经多次这样做了。
导致错误的原因可能是var / www / html文件夹是“rooted”。这意味着,root拥有它,而Apache(www-data user)没有足够的权限来访问该内容。有几种解决方案。您可以选择最符合您需求的产品。我将首先发布我的首选:
使用虚拟主机:在localhost中工作可能对某些人有用。我更喜欢使用以.dev结尾的虚拟主机。然后,我将文档根目录指向我拥有的文件夹项目,比localhost更易于访问。我created a script轻松做到这一切。
更改/var/www/html
的权限:选择该文件夹为www-data用户和www-group,并将其命名为777.警告:请确保将其上传到您的生产服务器,权限是可以的。
将Apache用户更改为root:在所有这些中,这是我最不推荐的,但它确实有效。