Zaphieon's avatar

Moved my project from 1 directory to another and shows index file list now

ok so set up a new sub domain and just renamed the directory actually so the new domain is pointing to it.. but get file list instead of the project loading up.. then if I switch the directory back to the first sub domain it loads fine.. can't clear the cache or anything else on the new subdomain.. any clue why it wouldn't just load up for this domain? i did change the .htaccess file.

0 likes
17 replies
D9705996's avatar

Can you provide details of your setup. Do you have full access to the server, shared hosting, etc

What web server (I guess apache). What subdomains are you using, what's your htaccess contain. What exactly did you move?

Zaphieon's avatar

ok

on a dedicated server.

had the app set up on lets say sub1.domain.com and i set up sub2.domain.com

the directory structure has a folder for each sub.. so i just changed sub2.domain.com_ then changes sub1 to sub2.

htaccess file just has

Options -MultiViews -Indexes

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{HTTP_HOST} sub.domain.com [NC]# RewriteCond %{SERVER_PORT} 80# RewriteRule ^(.*)$ https://sub.domain.com/$1 [R,L]

of course with the correct domain.

I do not believe its that though. I am still very new to laravel, and was thinking i could just change over the directory.. but seems something is tied to that directory. do i need to run an install in the new directory to get things going?

D9705996's avatar

Sorry I meant the actual configuration.

What I do for this type of requirement is used a name based vhost for each sub domain ax per below slimmed down example

VirtualHost *:80>
    DocumentRoot "/path/tosubdomain1"
    ServerName sub1.domain.com 
    <Directory "/path/tosubdomain1/public">
            AllowOverride All
            Options +FollowSymLinks +Indexes
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

VirtualHost *:80>
    DocumentRoot "/path/tosubdomain2"
    ServerName sub2.domain.com 
    <Directory "/path/tosubdomain2/public">
            AllowOverride All
            Options +FollowSymLinks +Indexes
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

This works for me but to be honest that's because I avoid mod_rewrite as it confuses me.

Zaphieon's avatar

well i know both subdomains are working. just one 1 i am getting the app running.. and on the other i see the files listed out.. because the app is not running.

So, that wouldn't be an issue with the vhost correct?

D9705996's avatar

There might be something funky going on with the rewrite conditions

Looking at a sample you could method co this

<VirtualHost *:80>
  
  ServerName domain.com
  ServerAlias *.domain.com

  DocumentRoot "/path/to/docroot/foo"

  # Then rewrite subdomains into different directories
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^(.*)\.domain.com$
  RewriteRule ^(.*)$   "/path/to/docfoot/%1/public/" [L]

</VirtualHost>

https://stackoverflow.com/questions/11169843/apache-virtual-host-definition-with-regex

If your going to be making more than a couple of sub domains you probably want to look at a dynamic solution bug if it's just a handful the manual vhosts removed a lot of magic

Zaphieon's avatar

well i have maybe 3 dozen or so domains on this server several with sub domains. ill check into this though.

SapporoGuy's avatar

Did you restart Apache so that it will reread the hosts file and if you are on a ubuntu style server did you dissite and ensite just in case?

skoobi's avatar

I had something similar on a project I transferred on a cPanel server which stupidly turned out to be Safari caching the DNS. Have you tried going incognito mode and testing it?

Zaphieon's avatar

flushed my dns, again the subdomain is loading it just is showing the ( index of/ ) list of files.

also just tried your suggestion about incognito same thing..

but my other sub is still working.. lol my only guess is somehow laravel is connected to that sub? and not the other?

skoobi's avatar

Ah damn lol... On cPanel , is the dns setup correctly for the subdomain, i.e. pointing to the correct folder.

Zaphieon's avatar

if it wasn't connected correctly i wouldn't see the listed out files that are in that directory correct? I mean i see the files there.. it just isn't rendering my app?

skoobi's avatar

Ah sorry i missed the listed out files.

Have you tried adding a index.php or index.html file with some gen code to see if its picking up the php file.

If i recall correctly, there is somewhere in cPanel that you can set how and which files to use, i.e. index.php, index.html etc. but that should be server wide not domain specific.

skoobi's avatar

It was called Index Manager...

You can set it in the .htaccess file too

DirectoryIndex index.php index.html

Zaphieon's avatar

yes and no.. I simply restructured the folders a bit putting the public folder in the root directory and everything else in a "project folder" and altered where the index pointed to the project files.

Please or to participate in this conversation.