我想创建一个别名" / blog"到" / home / mydomain / blog"所以当我请求http://www.mydomain.ca/blog/myfile.html时,它会返回/home/mydomain/blog/myfile.html
<VirtualHost *:80>
ServerName www.mydomain.ca
ServerAlias www2.mydomain.ca
Alias "/blog" "/home/mydomain/blog"
DocumentRoot "/home/mydomain/web"
<Directory "/">
Options +FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory "/home/mydomain/web">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
<Directory "/home/mydomain/blog">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =www2.mydomain.ca [OR]
RewriteCond %{SERVER_NAME} =www.mydomain.ca
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>
但是当我尝试请求http://www.mydomain.ca/blog/myfile.html时,我收到错误404。
我做错了什么?
答案 0 :(得分:1)
您似乎需要在 / etc / hosts 中添加一行来声明www.mydomain.ca和www2.mydomain.ca是localhost
127.0.0.1 www.mydomain.ca
127.0.0.1 www2.mydomain.ca
至少它对我有用