gpt4 book ai didi

ubuntu - 服务器上没有域名的 Ubuntu Apache2 站点上的别名

转载 作者:太空宇宙 更新时间:2023-11-03 17:07:07 26 4
gpt4 key购买 nike

我将此方法用于 3 个确实拥有域名的网站,并且一切正常。目前我正在开发另一个没有域名但可以通过服务器 IP 访问的网站,所以:

195.111.111.111/mywebsite.com/

而不是 http://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>

我所做的更改:

  1. 我更改了别名路径,现在它们没有引号。
  2. 我更改了 Order allow,denyallow from allRequire all granted
  3. 然后我创建了一个 <Directory... /var/www/uploads 指令.

关于ubuntu - 服务器上没有域名的 Ubuntu Apache2 站点上的别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49995539/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com