1

I used this method for 3 websites that do have a domain name and everything is working perfectly fine. Currently I am developing another website which has NO domain name yet but is purely accessible through server IP so:

195.111.111.111/mywebsite.com/

instead of http://mywebsite.com/

You get the point I guess :) anyways, all websites share the same upload folder due to the fact that it has 300.000+ photo's in it and I didnt wanted to upload multiple copies.

It works flawless for all websites except this one without domain name, I guess it works different.

When I go to:

195.111.111.111/mywebsite.com/product-image

I just get an error in my php file that the require once cannot be found, which is obviously correct but the point is... my PHP shouldnt even be able to get a request from this URL since I have an Alias, yet it goes to PHP.

Can anyone tell me what I did wrong? my current config file is below:

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]
Devbizz
  • 81
  • 1
  • 7
  • that's because when you go to `/product-image` the server loads the `index.php` file located in `/var/www/uploads` – Binar Web Apr 24 '18 at 13:33
  • Yeah I figured that out, but what do I have to do so it will use the Alias instead of the other one? :D – Devbizz Apr 24 '18 at 13:50
  • btw there is no index.php file in that location, just folders and pictures. And its not going to /var/www/uploads/ its going to the website itself instead of the alias :( – Devbizz Apr 24 '18 at 17:08
  • have you succeeded with solving your problem? i think you need to create a `` directive for your `Alias`. [check this](https://stackoverflow.com/a/15771712/9618184) – Binar Web May 09 '18 at 13:19

1 Answers1

0

After I installed SquirrelMail on an Ubuntu server, it wrote an Apache configuration file that looked like this:

Alias /squirrelmail /usr/share/squirrelmail

<Directory /usr/share/squirrelmail>
  Options FollowSymLinks
  php_flag register_globals off
  DirectoryIndex index.php
</Directory>

If we apply this to your project, we get an Apache configuration file that looks like this:

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>

Changes I made:

  1. I changed the Alias paths, now they are without quotes.
  2. I changed the Order allow,deny and allow from all with Require all granted
  3. And I created a <Directory... directive for /var/www/uploads.
Binar Web
  • 867
  • 1
  • 11
  • 26