I am having an issue with getting Laravel to work properly with Apache2. This is my config file, but whenever it go to my domain I see directory list, and I need to enter to portfolio/public to see the app. That's also what the url become (my-website.com/portfolio/public/).
Is there any way I can fix this?
I've been trying to deploy this app for 3 days and still had no success...
Great Thanks!
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName my-domain.com
ServerAlias www.my-domain.com
DocumentRoot /var/www/html/portfolio/public
<Directory /var/www/html/portfolio/public>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<Directory /var/www/html/portfolio/public>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory /usr/lib/cgi-bin>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
This might help you
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/index.php/$1 [L]
Source
Related
I have a website built based on PHP/HTML/CSS and which follow the MVC design pattern.
The website is the following : https://admin.site.com
It works well on Localhost. However, when I upload it to my apache2 server, I encounter a problem. It seems that the "/" get removed automatically after ".com" . As I need to be authentificated to access the website, I'm directly redirected to the login page but as the "/" has been removed, it is not working.
I get https://admin.site.comlogin/ instead of https://admin.site.com/login/
Before posting here, I tried to check everything but I run out of ideas.
Especially the fact that this same website works on a different subdomain that I initiated for testing : http://sub1.site.com
The only difference is that that this one does not have any SSL certificate but I don't know it's something that may cause the problem.
Here my different files in Apache2 server.
000-defaut.conf
<VirtualHost *:80>
ServerAdmin contact#site.com
ServerName site.com
ServerAlias sub1.site.com
DocumentRoot /var/www/sub1/interface/
<Directory /var/www/sub1/interface/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin contact#site.com
ServerName site.com
ServerAlias admin.site.com
Redirect permanent "/" "https://admin.site.com"
DocumentRoot /var/www/site/interface/
<Directory /var/www/site/interface/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
defaut-ssl.conf
ServerAdmin contact#site.com
ServerName site.com
ServerAlias admin.site.com
DocumentRoot /var/www/site/interface/
<Directory /var/www/site/interface/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
...
</VirtualHost>
.htaccess
`# Remove the question mark from the request but maintain the query string
RewriteEngine On
# Uncomment the following line if your public folder isn't the web server's root
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?$1 [L,R]
Do you have any insight about why it is not working and the slash get removed ?
I solved my issue simply :
I have added a trailing slash at the end to the redirect permanent directive.
Redirect permanent "/" "https://admin.site.com/"
I had some conflict as well with some directive. So I removed all the Directory directive to my conf file and let them only on my apache2.conf .
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I'm using Ubuntu wizzy as my local server and then I set up domain there which are
domain.svr
api.domain.svr
adm.domain.svr
And here is the problem. I've create exactly same configuration for all of them but why only adm.domain.svr doesn't work? It's always response 404 when I goes to http://adm.domain.svr/site/dashboard/ but it's okay when I try http://api.domain.svr/site/dashboard/
Here is my configuration
<VirtualHost *:80>
ServerAdmin localhost#gmail.com
ServerName domain.svr
DocumentRoot /home/shaf/web/domain.dev/frontend/web
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /home/shaf/web/domain.dev/frontend/web>
Require all granted
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog /home/shaf/log/domain-error.log
LogLevel warn
CustomLog /home/shaf/log/domain-access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin localhost#gmail.com
ServerName adm.domain.svr
DocumentRoot /home/shaf/web/domain.dev/backend/web
<Directory /home/shaf/web/domain.dev/backend/web>
Require all granted
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog /home/shaf/log/domain-adm-error.log
LogLevel warn
CustomLog /home/shaf/log/domain-adm-access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin localhost#gmail.com
ServerName api.domain.svr
DocumentRoot /home/shaf/web/domain.dev/api/web
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /home/shaf/web/domain.dev/api/web>
Require all granted
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog /home/shaf/log/domain-api-error.log
LogLevel warn
CustomLog /home/shaf/log/domain-api-access.log combined
</VirtualHost>
and here is my .htaccess which I placed on every domain web folder
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
Please give me advice about this, I really have no idea.
Your ServerName domain.svr is wrong. Apache can not route it. Try to rename it to adm.domain.svr
I just solve this by duplicate another directory to adm and try it but fail, so I create another 1 host so I have 4 host. 1 is duplicate for adm and it's work perfectly. I still didn't know what happen but seems only that folder didn't read the htaccess and I'm sure of it because I already try to swap sub domain but only adm folder doesn't read the htaccess file.
So here is my conclusion and I don't know this is correct or not but apache has cache of htaccess so I need to hard refresh the apache (only restart apache doesn't work because I already tried it several times and nothing happen) so maybe you need to restart your OS / Server and if you doesn't want it, try my way.
This is my /etc/apache2/sites-availables/mysite.com file configuration
ServerAdmin LOLILOL#LOL.com
ServerName www.example.com
Redirect permanent / http://www.example.com/
ServerAlias example.com
DocumentRoot /home/example/www
SuexecUserGroup example example
<Directory />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
<Directory /home/example/www>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Please can Someone tell my where to find the issue to redirect non www to www ?
PS : I can't acces to my site from http://example.com (Only from http://www.example.com/)
HELP ME PLEASE !!!!
I do it in the .htaccess.
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
I'm having a problem. I'm trying to get this url:
mySite.com/index.php?url=category/value1/value2/value3
From this:
MySite.com/category/value1/value2/value3
I have this .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
</IfModule>
everything is working fine if category is everything but "index", so if I put the URL:
MySite.com/content/tv/color
The array $_GET is equal to:
Array
(
[url] => content/tv/color/
)
but when i put:
MySite.com/index/option1/option2
the array is empty
Array()
I checked my apache.conf file and I can't see the problem.
<VirtualHost *:80>
ServerAdmin user#site.com
DocumentRoot /home/htdocs
<Directory />
AllowOverride all
</Directory>
<Directory /home/htdocs>
#>>>>>HERE I HAVE MY TEST APP <<<<<<<<
DirectoryIndex index.html index.php
Options FollowSymLinks MultiViews
RewriteEngine ON
AllowOverride all
Order allow,deny
allow from all
</Directory>
Alias /simplesaml /var/simplesamlphp/www
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
You need to turn off MultiViews option by prepending minus sign - before it like -MultiViews.
Actually I'm not sure why you turned it on explicitly. Was it just a config copy-paste?
Also if you don't need FollowSymLinks (I'm sure you don't need it) - turn it off as well.
I was making a .htaccess file to run a framework that I was testing, but when I tried to access to my localhost, the folder where is located the framework's files didn't show up.
If I try to access, requesting the localhost/my_hidden_folder/ this fires a 500 error, internal server error.
This behaviour is result of some wrong configuration with my apache|.htaccess, I'm pretty sure because the same .htaccess in another server works fine.
Here is my .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
And here is my default file from /etc/apache2/sites-available:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /var/www/entrega2>
AllowOverride All
</Directory>
<Directory /var/www/unlp>
AllowOverride All
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Both folders, /var/www/unlp and /var/www/entrega2 have the same .htaccess file, and both are hidden.
The most basic redirect in the .htacces file doesn't work, in my localhost, but in the server works. Maybe I have a module disabled?
Is there a +FollowSymlinks in .htaccess? This usually does the 500 error on Linux systems that have already activated the option or on Windows.
Try to run phpinfo() to make sure the mod-rewrite is activated.
Create simple php file in your web root folder, which contains:
<?php
phpinfo();
?>