Virtual Hosts Laravel - I need URL addres with name of my aplication - laravel-5

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 ;) –

Related

Laravel - set /public as root on LAMP stack

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).

Laravel status not found, missing route

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?

Redirect /var/www/html/app/api/* to /var/www/html/api/*

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>

Codeigniter Cannot Remove index.php after move to virtual host

I created the virtual in wamp server. Everything is working but i can't able to remove the index.php. I don't know how to write the .htaccess.
Here is the details
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot E:/Projects/OnGoing/bonanza/dev.bonanza.com
ServerName dev.bonanza.com
<Directory "E:/Projects/OnGoing/bonanza/dev.bonanza.com">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and my htaccess
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Allow these directories and files to be displayed directly:
# - index.php (DO NOT FORGET THIS!)
# - robots.txt
# - favicon.ico
# - Any file inside of the media/ directory
RewriteRule ^(index\.php|robots\.txt|favicon\.ico|media|uploads|js|css|images|plugins|source|files|fonts|lib|plugins) - [PT,L]
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php?/$0 [PT,L,QSA]
Did you setup your host file correctly to read the path of your site? For me I used this all the time works fine in development server.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

vHost RewriteRule is creating a 500 Error

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.

Resources