我将此方法用于 3 个确实拥有域名的网站,并且一切正常。目前我正在开发另一个没有域名但可以通过服务器 IP 访问的网站,所以:
195.111.111.111/mywebsite.com/
我猜你明白了:)无论如何,所有网站都共享同一个上传文件夹,因为它有 300.000 多张照片,我不想上传多份。
它适用于所有网站,除了这个没有域名的网站,我猜它的工作方式不同。
当我去:
195.111.111.111/mywebsite.com/product-image
我只是在我的 php 文件中收到一个错误,找不到 require once,这显然是正确的,但重点是......我的 PHP 甚至不应该能够从这个 URL 获得请求,因为我有一个别名,但它转到 PHP。
谁能告诉我我做错了什么?我当前的配置文件如下:
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mywebsite.nl/
#ServerName mywebsite.nl
#ServerAlias www.mywebsite.nl
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias "/product-image" "/var/www/uploads"
<Directory /var/www/mywebsite.nl/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =mywebsite.nl [OR]
RewriteCond %{SERVER_NAME} =mywebsite.nl
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
最佳答案
我在 Ubuntu 服务器上安装 SquirrelMail 后,它编写了一个如下所示的 Apache 配置文件:
Alias /squirrelmail /usr/share/squirrelmail
<Directory /usr/share/squirrelmail>
Options FollowSymLinks
php_flag register_globals off
DirectoryIndex index.php
</Directory>
如果我们将其应用到您的项目中,我们将获得如下所示的 Apache 配置文件:
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mywebsite.nl/
ServerName mywebsite.nl
ServerAlias www.mywebsite.nl
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /product-image /var/www/uploads
<Directory /var/www/mywebsite.nl>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/uploads>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
我所做的更改:
- 我更改了别名路径,现在它们没有引号。
- 我更改了
Order allow,deny
和allow from all
与Require all granted
- 然后我创建了一个
<Directory...
/var/www/uploads
指令.
关于ubuntu - 服务器上没有域名的 Ubuntu Apache2 站点上的别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49995539/