I'm trying to install Laravel on Wamp server and I'm getting this error:
{"status":"Not Found","error":true,"error_code":"missing_route","message":"Route not found.","data":[]}
Been searching for a while now and can't figure out what it is. I checked and triple checked if I added corectly my project in hosts file, if virtual host is set properly, also if rewrite module is activated and if .htaccess file in the public folder is as it should.
Hosts File:
127.0.0.1 app.my-site.com
Vhosts
<VirtualHost *:80>
ServerAdmin webmaster#my-site.com
DocumentRoot "C:/wamp/www/my-site/public"
ServerName app.my-site.com
<Directory "C:/wamp/www/my-site/public">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "logs/my-site-error.log"
CustomLog "logs/my-site-access.log" common
</VirtualHost>
.htaccess in public folder
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Can anybody suggest what could be wrong?
Related
I made a virtual host on the remote server and it works, but I would like to include the name of the app in the url address...
example: 10.10.20.30 - work, the homepage of the app opens, but 10.10.20.30/e-lab don't work...
These are my files for a virtual host:
httpd-vhost.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/e-lab/public"
ServerName e-lab.test
<Directory "C:/xampp/htdocs/e-lab/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
hosts
127.0.0.1 localhost
127.0.0.1 e-lab.test
and htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ / [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Thanks! ;)
I solved the problem ... In the localhost links works ok, example: <a href=/login> , but over the remote server this slash line deletes the folder name (name of aplication), so i put it all links {{url('something')}} and now it's ok ... thanks anyway ;) –
I'm trying to deploy a Laravel App on a LAMP stack although I am having trouble setting the document root as /public. I've looked at several answers on here already for similar problems but am yet to find my problem or a solution. I ideally I want to do it through the Apache web server and not modify any Laravel files.
I copied the default .conf file a change it to the following using sudo nano /etc/apache2/sites-available/subdomain.website.com.conf
<VirtualHost *:80>
ServerAdmin email#gmail.com
ServerName subdomain.website.com
ServerAlias www.subdomain.website.com
DocumentRoot /var/www/subdomain.website.com/public_html/public
<Directory /var/www/subdomain.website.com/public_html/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.subdomain.website.com [OR]
RewriteCond %{SERVER_NAME} =subdomain.website.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
After the I ran the following commands in this order.
sudo a2ensite subdomain.website.com.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo service apache2 restart
I cleared cookies, did a hard refresh and it hasn't worked. I still have to go to https://subdomain.website.com/public to view the website. Is there anything I have missed or anything I can do find out what the problem may be?
The .htaccess file in the /public folder contains the following
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
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]
</IfModule>
This virtualhost is for http:// (Port 80). You have a rewrite rule that redirects to https:// as soon as it hits this virtualhost.
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.subdomain.website.com [OR]
RewriteCond %{SERVER_NAME} =subdomain.website.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Therefore, you need to apply your changes to the other virtualhost that is serving this domain from https:// (Port 443).
I've seen a lot of similiar topics and I tried all of them and previously it worked, every time different one, but now nothing...
So I want to remove /public from my URL and it works for laravel-public_html but not for build version
I'm using VPS (CentOS 7 with CWP 7)
My structure is like this:
/home/admin/
-laravel
-public_html (public folder for laravel)
-laravel_build
-build (public folder for laravel_build)
and with that I have build.mypage.com and www.mypage.com
httpd.conf
...
ServerRoot "/usr/local/apache"
...
DocumentRoot "/home/admin/public_html"
<Directory "/home/admin/public_html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
index.php (public_html)
require __DIR__.'/../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
index.php (build)
require __DIR__.'/../laravel_build/bootstrap/autoload.php';
$app = require_once __DIR__.'/../laravel_build/bootstrap/app.php';
Should I add something in .htaccess , and if yes, where do I need to put that .htaccess?
Edit: I already have .htaccess in public folders for laravel routes(mod _rewrite)
Assuming you are using something like MAMP or XAMP, if possible do not add anything in httpd.comf, instead you could do something
like below in your httpd-vhosts.conf.
You may have to look for a directory in your environment where to put the virtual host file (and sometime you have to uncomment that path in your httpd.conf)
Example of entry in httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin yourEmail#domain.com
DocumentRoot "/home/admin/laravel/public_html"
ServerName MySite1.com
ServerAlias MySite1.com
ErrorLog "logs/MySite1_com-error.log"
CustomLog "logs/MySite1_com_access.log" common
php_value error_log "logs/php_error.log"
</VirtualHost>
<VirtualHost *:80>
ServerAdmin yourEmail#domain.com
DocumentRoot "/home/admin/build"
ServerName subdomain.MySite1.com
ServerAlias subdomain.MySite1.com
ErrorLog "logs/subdoamain-MySite1-error.log"
CustomLog "logs/subdoamain-MySite1-error.log" common
php_value error_log "logs/php_error.log"
</VirtualHost>
Add two entries for both the apps.
I feel so stupid now, the problem was actually that I did not Hard Reset and Clear Cache in Google Chrome so it loaded previous configuration
For others that have similiar problem, solutions to try:
1.Create vHosts for subdomain and domain
2.Put .htaccess in public folder, not laravel folder
My current .htaccess is as follows(both public_html and build):
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
</IfModule>
I have a frontend app at /var/www/html/app and the API for that app is at /var/www/html/api. There is a virtual host set up for /var/www/html/app, with the name example.com. Now, I want it so what when a user visits example.com/api, it will redirect all requests to /var/www/html/api.
Example:
User enters http://example.com/api/some/call into their browser - instead of the server looking for /var/www/html/app/api/some/call, it will look for /var/www/html/api/some/call.
What is the best way to get this done? I tried using symbolic links which works for just /api, but not for variable routes after /api. I am thinking I can get it working with mod rewrite, but I am not that familiar with it.
UPDATE
Here is the config for example.com in /etc/apache2/sites-available:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/app
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html/app>
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>
Here in the .htaccess file in /var/www/html/app (and the same one at /var/www/html/api):
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Below you will find my current vHost entry that I am using for a site that I currently have under development. This vHost entry works fine when I have it on my local machine, but when I push my code to my staging server that is running this same vHost record I receive a 500 Internal Server error.
The machine I'm running this vHost on is running Apache 2.2.9 (Debian).
<VirtualHost 206.217.196.61:80>
SuExecUserGroup 13labs 13labs
ServerAdmin aellis#1three.com
ServerName admin.13labs.net
ServerAlias admin.13labs.net
DirectoryIndex index.php
DocumentRoot /var/www/13labs.net/html/admin/
ErrorLog /var/www/13labs.net/logs/error.log
# Hide .svn Directories
<DirectoryMatch "\.svn">
Order deny,allow
deny from all
</DirectoryMatch>
# FastCGI
Alias /fcgi-bin/ /var/www/13labs.net/fcgi-bin/
AddHandler php-fastcgi .php
AddType application/x-httpd-php .php
Action php-fastcgi /fcgi-bin/admin-php.fcgi
<Directory /var/www/13labs.net/fcgi-bin/>
SetHandler fcgid-script
AllowOverride None
Options -Indexes +ExecCGI -FollowSymlinks -SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/13labs.net/html/admin/>
AllowOverride None
Options -Indexes -FollowSymlinks -SymLinksIfOwnerMatch
FileETag All
</Directory>
# Rewrite Logic
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^/(.+)$ /index.php/$1 [PT,QSA,L]
Thanks for any help that you can provide.
Best regards,
Andrew
After many trial and errors I have found that the working RewriteRule needs to be the following:
RewriteRule ^.*$ /index.php$1 [PT,QSA,L]
Then in PHP I need to be using $_SERVER['REQUEST_URI'] instead of $_SERVER['PATH_INFO'] to make sure my PHP script see the passed in URI.