All routes causing 404 - php

We are trying to go live with our Laravel project on an Ubuntu server running Apache. While all routes and functionality works locally, after going live, all routes that are not the home route result in a 404 error.
I am using the default laravel .htaccess in the /public directory.
My /etc/apache2/sites-available looks as follows:
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/mydomain.com/public
<Directory /var/www/mydomain.com/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The /mydomain.com/ root directory does not currently contain any .htaccess.
I enabled modrewrite using a2enmod rewrite and restarted apache after every change.
Has anyone else run into this issue? I appreciate any suggestions on how to resolve.
Thanks in advance!

You write mydomin.com in every rows. But later you talk about mydomain.com folder. (Note the A). Is it just a mistyping?
Update: The problem is an other mistyping: directories should be the same on the following lines:
DocumentRoot /var/www/html/mydomain.com/public
<Directory /var/www/html/mydomain.com/public>

Related

Symfony project shows directory listing index instead of index page

I am new to Symfony, and I've just created a new project on Windows server + Php7.3 + Apache 2.4.
The project folder is located at C:\Apache24\htdocs\symfony.
When I access that folder from my web browser, I see the directory listing page it should show the index page in the public folder.
Here is my code in apache:
<VirtualHost *:90>
ServerAdmin abc#abc.com
DocumentRoot "${SRVROOT}/htdocs/"
ServerName localhost
<Directory "${SRVROOT}/htdocs/symfony/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
And i tried to use .htacess option as in Symfony guideline with install symfony/apache-pack, but no luck:
<VirtualHost *:90>
ServerAdmin abc#abc.com
DocumentRoot "${SRVROOT}/htdocs/"
ServerName localhost
<Directory "${SRVROOT}/htdocs/symfony/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
the .htaccess file had been created in public folder.
i have tried to install the demo application too, the same issue.
Wordpress or other applications have been installed without issue.
Thank you.
Shouldn't the DocumentRoot also be pointing to the Symfony public directory?
<VirtualHost *:90>
ServerAdmin abc#abc.com
DocumentRoot "${SRVROOT}/htdocs/symfony/public"
ServerName localhost
<Directory "${SRVROOT}/htdocs/symfony/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

laravel project not loading css with apache artisan serve working fine

I've created a Laravel Project, which I have deployed previously with apache2, and working great.
As I finished with my latest deployment, I found that no external CSS was being loaded when I was done with. So I did a check on all step many times over, but I don't think I have missed on anything.
However, upon running with php artisan serve everything works fine.
Here is my virtual_host config file:
<VirtualHost *:80>
ServerAdmin admin#project
DocumentRoot /var/www/html/project/public/index.php
ServerName example.com
ServerAlias www.example.com
DirectoryIndex index.php
<Directory /var/www/html/project/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
In virtualhost configuration, you should try using
<VirtualHost *:80>
ServerAdmin admin#project
DocumentRoot /var/www/html/project/public
ServerName example.com
ServerAlias www.example.com
DirectoryIndex index.php
<Directory /var/www/html/project/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Remove public folder from <Directory> and also remove index.php from DocumentRoot.

Laravel 5 on CentOS 7 Not Working On Domain

I've installed Laravel 5 on CentOS 7 with ease. Made .htaccess changes and and generated application key. My .conf file is like this:
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot "/var/www/html/laravel/public"
ServerAlias www.mydomain.com
ServerAdmin x#localhost
<Directory "/var/www/html/laravel">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
But when i try to open it via www.mydomain.com it opens Apache Testing 123.. page. And when i try www.mydomain.com/laravel/public, i can see default laravel page.
What am i missing?
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot "/var/www/html/laravel"
ServerAlias www.mydomain.com
ServerAdmin x#localhost
<Directory "/var/www/html/laravel">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>
Directory and document root should be the same
I had the exact same problem some months ago, check in your .htaccess for the following lines
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
If it's like this, include index.php so when apache is looking in the public folder it will use that file to redirect your routes. Also be sure you are loading the php module.
LoadModule php7_module modules/libphp7.so

Subdomain Apache2 Different Methods nothing working

I have got an website example.com
I want to have subdomain blog.example.com (which content is located in /var/www/blog).
I generated new IP for subdomain on my server. The main domain is on xxxx01 and the subdomain is on xxxx02. Evertyhing is made in domain provider.
So I made a file here apache2/sites-available/blog:
<VirtualHost xxxx02:80>
ServerName blog.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/blog
<Directory /var/www/blog>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/red-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/red-access.log combined
</VirtualHost>
I enabled subdomain with a2ensite.
etc/hosts:
127.0.0.1 localhost
xxxx02 blog.example.com
What I have to do? Help me guys please!

Apache2.2 not running php scripts for virtual host

Hey guys I have a lamp setup in a virtual-box (running Ubuntu-server 12.04 with apache2.2 and php5.3.10). I have a virtual host file which looks like this.
<VirtualHost *:80>
ServerAdmin admin#demosite.com
ServerName demosite.dev
ServerAlias www.demosite.dev
DocumentRoot /var/www/demosite
<Directory /var/www/demosite>
Options Indexes FollowSymLinks MultiViews
AllowOverride ALL
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/bfhosting.log
LogLevel debug
</VirtualHost>
I have an index.php file in /var/www/index.php and the server runs that file fine. But it's not running any php code that's inside my other website's folder i.e /var/www/demosite.

Categories