2

I've created a subdomain . (track.example.com)

I use direct Admin panel so I set the roots for

public : /domains/track.example.com/public_html

private : /domains/track.example.com/private_html

I copied my files to both folders above. Now when I try to load track.example.com , It throws 403 error. what is the problem ?

( Update : when I try to load the address with HTTPS . it works fine ! )

( Update 2 : When I try to request index.php directly , The site loads fine ! )

My log : 2021-12-09 09:45:56.848516 [INFO] [16025] [151.246.223.141:23540#APVH_www.track.example.com] Auto Index is disabled for [/home/h170081/domains/example.com/public_html/track/], access denied

htaccess content :

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !=localhost
RewriteCond %{HTTP_HOST} !=127.0.0.1
RewriteCond %{REMOTE_ADDR} !=127.0.0.1
RewriteCond %{REMOTE_ADDR} !=::1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ $1 [R=302,L]

ErrorDocument 404 /notfound.php
  • `403` means you don't have permission to visit the directory your subdomain is pointing to. – Amit Verma Dec 09 '21 at 09:24
  • I know that ! the question is why ? – Jack Forest Dec 09 '21 at 09:25
  • Please share your htaccess file in the question. – Amit Verma Dec 09 '21 at 09:37
  • I did . but I doubt that there is a problem with it. I deleted it and still get the error ! – Jack Forest Dec 09 '21 at 09:42
  • The only way to know why you are getting an error is to look in your web servers log files. There is no way for us to do so. Rather than asking here, you need to look there. – Stephen Ostermiller Dec 09 '21 at 09:42
  • Try adding this line to your htaccess `DirectoryIndex index.html` if you don't have an html index file then you can put any other file that you want to show when the directory is requested. – Amit Verma Dec 09 '21 at 09:54
  • Tried that. no chance. – Jack Forest Dec 09 '21 at 09:59
  • Since you are expecting `index.php` to load then `DirectoryIndex index.php` (not `index.html`) would be required. It's possible this is already set for HTTPS and not for HTTP vHost. – MrWhite Dec 09 '21 at 09:59
  • Well I tried it but nope . Is it possible that this is a problem from the server that I can't reach? – Jack Forest Dec 09 '21 at 10:01
  • "so I set the roots for" - How do you seemingly have 2 document roots? How is this actually configured? There can only be one "`DocumentRoot`" per host. – MrWhite Dec 09 '21 at 10:01
  • There are 2 fields . one for public_html and one for private_html in direct admin panel. – Jack Forest Dec 09 '21 at 10:05
  • Does it work if you request the file directly? – MrWhite Dec 09 '21 at 10:21
  • When I request the file directly , It is successfully loaded and it redirects to https ! What do you think is the problem MrWhite?! – Jack Forest Dec 09 '21 at 10:30
  • 1
    "and it redirects to https" - Presumably your application is doing that? Just try adding some nonsense at the top of the `.htaccess` file - do you get a 500 error when requesting `track.example.com` over HTTP? The problem you are seeing suggests that `DirectoryIndex` is not set correctly (as already mentioned). However, there could be multiple problems... are `.htaccess` overrides enabled for HTTP? (Adding the _nonsense_ to the file checks for that.) If not then adding `DirectoryIndex` to `.htaccess` is not going to help - but this then becomes a server config issue. – MrWhite Dec 09 '21 at 12:06
  • 1
    It's quite possible that HTTP and HTTPS result in a different response, these are often handled by separate configs. However, this would then likely be a server config issue. – MrWhite Dec 09 '21 at 12:08
  • I spoke to the server support and they said that the domain name of track.example.com has a different host IP . I presume they want me to pay more ?! to buy another host ?! I tested it and no chance . I'm certain now that this is a server config issue that I do not have access to. Thank you so much for your guide. – Jack Forest Dec 09 '21 at 17:51

1 Answers1

1

I've faced same problem before. You will need to move all of your track.example.com content to this path : /domain/example.com/public_html/track

Also you need to remove the existing settings for subdomain and set it to default.

The reason for this is that your service provider set the allowed path to the path I mentioned.

Nima
  • 118
  • 9