I keep trying to configure it so that the domain symfony.local would link to the app_dev.php, but I also keep getting forwarded to the xampp page.
My hosts file is:
127.0.0.1 symfony.local
My httpd-vhost is:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName symfony.local
DocumentRoot "C:\xampp\htdocs\testAS\web"
DirectoryIndex app_dev.php
<Directory "C:\xampp\htdocs\testAS\web">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app_dev.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
I'm using Windows 8. Appreciate any feedback.
I assume it's a fairly recent version of xampp? There is a new directive "Require local" that popped up a few years ago. I remember being stumped by it.
<Directory "C:/home/ahundiak/zayso2016/cerad3/web">
## Options Indexes FollowSymLinks
AllowOverride All
Require local ## Add This
</Directory>
<VirtualHost *:80>
ServerName local.api.zayso.org
DocumentRoot "C:/home/ahundiak/zayso2016/cerad3/web"
</VirtualHost>
I am not an expert on configuring this. The above works for me using the Symfony 2 .htaccess file.
may be it issue of your hosts file entry of symfony.local and local ip address or may between them only TAB(on keyboard) require ...
OR if above answer not work follow below
please follow this link Click Here it help you solve your issue of not show symfony project
Related
I want to load my Laravel 5.8 project with Virtual Host on XAMPP. So here is what I did:
I opened up C:\Windows\System32\drivers\etc\hosts and put this:
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 local.nanoclub.ir
Then at C:\xampp\apache\conf\extra\httpd-vhosts.conf, I added this:
<VirtualHost local.nanoclub.ir:80>
DocumentRoot "C:/xampp/htdocs/badges/public"
ServerName local.nanoclub.ir
ServerAlias *.local.nanoclub.ir
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/badges/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And also added this to my project, public .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
But now when I want to run local.nanoclub.ir on browser, I get this:
So what's going wrong here? I used to access this local.nanoclub.ir correctly but now it loads this screen.
How to solve this issue?
You need to grant access to this directory.
You can grant this access in your virtual host definition or in the apache2.conf
In virtual host definition
<VirtualHost local.nanoclub.ir:80>
DocumentRoot "C:/xampp/htdocs/badges/public"
ServerName local.nanoclub.ir
ServerAlias *.local.nanoclub.ir
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/badges/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
# The missing one
Require all granted
</Directory>
</VirtualHost>
In apache2.conf
<Directory C:/xampp/htdocs/badges/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Notice: Don't forget to restart apache after changing configuration.
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 have two different domains that are supposed to point exactly to the same index.php file:
diegodeoxossi.com.br
lumelivros.com.br
All DNS settings for both are the same. Apache default vhost is disabled and both domains has the same vhost configs, as below:
#1 diegodeoxossi.com.br
<VirtualHost *:80>
ServerName diegodeoxossi.com.br
ServerAlias *.diegodeoxossi.com.br
DocumentRoot /var/www/html
AllowEncodedSlashes On
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
SSLProxyEngine On
</VirtualHost>
#2 lumelivros.com
<VirtualHost *:80>
ServerName lumelivros.com
ServerAlias *.lumelivros.com
DocumentRoot /var/www/html
AllowEncodedSlashes On
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
SSLProxyEngine On
</VirtualHost>
They all point to the same root directory, and both pass by .htaccess - and here is the problem: my last line in .htaccess is:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* site/index.php?APPLR_friendlyURL=1 [L,QSA]
The thing is: domain #1 works great; domain #2 pass by this rule and keeps showing Apache's default page. Does any one have a clue on how to fix it?
ServerName lumelivros.com
You are missing the .br TLD that is present in the example, so the request will never match the stated VirtualHost. The request is likely being caught by the "default" vHost container and the expected .htaccess file is not even being processed.
Apache default vhost is disabled
You can't "disable" the default vhost. Whatever vHost is defined first is considered the default. So, there is always a default, even if you have not explicitly defined one.
However, as already mentioned in comments, if you want both domains to serve the same site (and the response is determined by the application) then you should only have a single vHost container that serves both domains.
For example:
<VirtualHost *:80>
ServerName diegodeoxossi.com.br
ServerAlias *.diegodeoxossi.com.br
ServerAlias lumelivros.com.br
ServerAlias *.lumelivros.com.br
:
Aside:
RewriteEngine on
SSLProxyEngine On
These two directives are out of place here. (?)
I have just downloaded the latest version of XAMPP with PHP version 7.2.4. I have made a very simple PHP validation for a HTML form and when I press submit it comes up with the following:
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4
I'd don't know what the problem is as I have tried changing Require none to Require all granted.
Please Help!
I have experienced this problem and found out that localhost link is not configured in
httpd_vhosts.conf.
So I added this line at the bottom part of httpd_vhosts.conf
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs"
ServerName localhost
</VirtualHost>
Well, probably this must be happening because the localhost link is not configured in your xamp vhost, try to look for the vhosts configuration file and add the same one there. Just add this block of code making the appropriate path changes until your repository so that you can access the localhost:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#hcode.com.br
DocumentRoot "C:\ecommerce"
ServerName www.hcodecommerce.com.br
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "C:\ecommerce">
Require all granted
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</Directory>
</VirtualHost>
By default in httpd.conf your entire system directory "/" is secured and not allowed access
in httpd.conf:
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
Add the below additional under the above
<Directory /home>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
Change /home to your hosted installation public directory - e.g. /projects or /devsite.local etc...
For more info on Apache see here: https://httpd.apache.org/docs/current/mod/core.html#directory
The 'Options' are typical .htaccess directives - change as needed
The 'AllowOverride All' gives access to the /home folder and everything under it
The 'Require local' makes sure only localhost / 127.0.0.1 has access to folder and files under /home
Hope this helps :D
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.