My basic project is in C:\xampp\htdocs\site.local\www
I can run my app whith http://site.local/basic/web/index.php
But I want run it as http://site.local/index.php
How can I solve this problem?
I changes my httpd.conf :
DocumentRoot "C:/xampp/htdocs/site.local/www/basic/web"
<Directory "C:/xampp/htdocs/site.local/www/basic/web">
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
AllowOverride All
Require all granted
</Directory>
But it doesn't work
Your solution is simply named Virtual Host. In C:\xampp\apache\conf\extra\httpd-vhosts.conf add the following:
<VirtualHost 127.0.10.80:80>
##ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "C:/xampp/htdocs/site.local/www/basic/web"
ServerName site.local
ErrorLog "logs/site.local.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
Then, run the notepad as administrator and from it open the hosts file in C:\Windows\System32\drivers\etc\hosts and add the following line to its end:
127.0.10.80 site.local
Save the both files and restart the Apache Server and restore the default .httaccess.
Notice: the IP 127.0.10.80 is called internal loop IP and it is dedicated for local hosting. It may be any other value starts with 127, such as 127.0.0.1 (the default one)
Related
I am trying to configure a Wordpress project on my localhost, but when I open the browser on localhost I only see the files in the root of my wordpress project.
If I click on index.php or access localhost/index.php it executes the PHP as expected.
I have installed apache 2.4, php 7.2 and php-apache 7.2.
My project is in /srv/http/mysite:
The relevant lines in /etc/httpd/conf/httpd.conf file:
LoadModule rewrite_module modules/mod_rewrite.so
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Note: Since httpd.conf is very big I showed only the lines I know to be relevant. If this is not enough I can upload the entire file on pastebin.
The file /etc/httpd/conf/extra/httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin webmaster#test.localhost
DocumentRoot "/srv/http/mysite/"
ServerName test.localhost
ServerAlias test.localhost
ErrorLog "/var/log/httpd/test.localhost-error_log"
CustomLog "/var/log/httpd/test.localhost-access_log" common
<Directory "/srv/http/mysite/">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
The file /srv/http/mysite/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
My /etc/hosts file:
127.0.0.1 localhost
127.0.1.1 mycomputer_name
127.0.2.1 test.localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
About this last file I noticed that if I remove the <IfModule ...> and </IfModule> site it works and redirects to index.php, but I would prefer not to change this file since it works the way it is on the remote server that uses ubuntu.
The main question is why this is not working but I would be also happy to know what the <IfModule mod_rewrite.c> is doing and why it is being ignored even though LoadModule rewrite_module modules/mod_rewrite.so is enabled.
I know this is not an easy question but I have not found anyone with this same problem on the web. I will be very grateful for any help.
Apache needs to be setup to recognize your index files (in this case index.php)
Do you have the following in your Directory
DirectoryIndex index.php
So
<Directory "/srv/http/mysite/">
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
In httpd.conf you should have something like...
<IfModule dir_module>
DirectoryIndex index.php index.htm index.html
</IfModule>
This would be your catch-all fall-back.
And then in your httpd-vhosts.conf one of many site descriptions might look something like...
<VirtualHost *:8080>
ServerAdmin admin#siteName.com
DocumentRoot "e:/Stack/Sites/siteName/web"
ServerName siteName
ServerAlias siteNameUser
<Directory "e:/Stack/Sites/SiteName/web">
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/siteName.error.log"
CustomLog "logs/siteName.access.log" common
</VirtualHost>
Note: The DirectoryIndex index.php in httpd-vhosts.conf site declaration is unnecessary if you included the fall-back defaults in httpd.conf
If you are not wanting to use default port 80 then in either file have something like: Listen 8080
For localhost I use: in httpd.conf... Listen 127.0.0.1:8080 and in httpd-vhosts.conf Listen 8080
In your hosts file you will need to define something like...
127.0.0.1 siteName siteNameUser www.siteName.com
Currently using: Apache/2.4.33 (Win64) PHP/7.2.4 ~ MySql 5.7.22 homebrew stack.
The httpd-vhosts.conf example portion is for Drupal 8.x - For WP your DocumentRoot and Directory will differ.
You can listen on multiple ports such as 8080 for dev, 8081 for test, 8082 for prod. Also you can have many different site definitions in your httpd-vhosts.conf file.
I prefer to define all sites in httpd-vhosts.conf, but you could just place them in httpd.conf
I am new to laravel and trying to learn laravel but I am stuck while
entering a server name in httpd-vhosts.conf I entered this in httpd-vhost.contf:
<VirtualHost *:80>
DocumentRoot "D:/Xampp/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/Xampp/htdocs/lsapp/public"
ServerName lsapp.dev
</VirtualHost>
and in system32 host file :
127.0.0.1 localhost
127.0.0.1 lsapp.dev
See the error in homepage
Use run this command, in project root
php artisan serve --host=lsapp.dev --port=80
Be sure to stop mysql from xampp , which uses port 80,
Above command require to set 127.0.0.1 lsapp.dev in your host file, as you did already
If you want to go without command set DocumentRoot in httpd-vhost.contf as you did already
"D:/Xampp/htdocs/lsapp/public"
ServerName lsapp.dev
And in host file
127.0.0.1 lsapp.dev
And restart apache, stop and then start apache to reflect, and hit lsapp.dev browser
<VirtualHost lsapp.dev:80>
DocumentRoot "D:/Xampp/htdocs/lsapp/public"
ServerAdmin laravel.dev
<Directory "D:/Xampp/htdocs/lsapp/">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
and don't forget the .htaccess file in public folder
Apache (from laravel docu...)
The framework ships with a public/.htaccess file that is used to allow URLs without index.php. If you use Apache to serve your Laravel application, be sure to enable the mod_rewrite module.
If the .htaccess file that ships with Laravel does not work with your Apache installation, try this one:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
If your web host doesn't allow the FollowSymlinks option, try replacing it with Options +SymLinksIfOwnerMatch.
I have defined such virtual host on a local Apache server.
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "c:/wamp/www/yii/frontend/web"
<Directory "c:/wamp/www/yii/frontend/web">
AllowOverride all
Require all granted
</Directory>
Alias /admin "c:/wamp/www/yii/backend/web"
<Directory "c:/wamp/www/yii/backend/web">
AllowOverride all
Require all granted
</Directory>
ServerName florist
ErrorLog "logs/yii-error.log"
CustomLog "logs/yii-access.log" common
</VirtualHost>
URL http://florist/admin works correctly and processed by /backend/web/index.php.
But URL http://florist/admin/login have processed by /frontend/web/index.php
I found this out when I placed exit() function with appropriate message in appropriate index.php
What's wrong may be in the alias?
Try add .htaccess in admin subfolder:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
I have created simlink to c:\wamp\www\yii\backend\web
mklink /D c:\wamp\www\yii\frontend\web\admin
c:\wamp\www\yii\backend\web
and add Options FollowSymLinks in the virtual host definition.
It's resolve a problem.
I am trying to make a virtual host for a codeigniter project. I have done this in httpd-vhosts.conf:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\CI_projects\facebook-login"
ServerName dev.facebook-login.com
<Directory "C:\xampp\htdocs\CI_projects\facebook-login">
Require all granted
</Directory>
</VirtualHost>
and in application/config/config.php,
$config['base_url'] = 'http://dev.facebook-login.com';
and
$config['index_page'] = '';
the browser opens the landing page. but when transiting from any other uri it says object not found.
And when i configure httpd-vhosts.conf like this:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\CI_projects\facebook-login\index.php"
ServerName dev.facebook-login.com
<Directory "C:\xampp\htdocs\CI_projects\facebook-login\index.php">
Require all granted
</Directory>
</VirtualHost>
It arises problem with assets things, i,e images and some css doesnt loads. How can I solve it?
I am on windows 10 and I use xampp with virtual host this is way I set up.
Put forward slash at end of base url
$config['base_url'] = 'http://dev.facebook-login.com/';
First go to
Windows > System32 > drivers > etc > host
You may need to open as administrator to be able to save it
You might see some thing like
127.0.0.1 localhost
Below that create another one for dev.facebook-login.com like example:
127.0.0.1 localhost
127.0.0.1 dev.facebook-login.com
Save it
Then go to the
xampp > apache > conf > extra > httpd-vhosts.conf
open it as administrator so you can save it.
No need for the index.php on DocumentRoot
<VirtualHost *:80>
##ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "C:/xampp/htdocs/CI_projects/facebook-login"
ServerName dev.facebook-login.com
##ServerAlias www.dummy-host.example.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
Save it and restart the severs.
I use this for my htaccess
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
httpd-vhosts.conf
Listen 1122
<VirtualHost *:1122>
DocumentRoot "D:\laragon_server\www\hugpong_production"
<Directory "D:\laragon_server\www\hugpong_production">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
https://www.namecheap.com/support/knowledgebase/article.aspx/10026/33/installing-an-ssl-certificate-on-xampp/
php 8 is not ready for CI4 as of jan 2021!
XAMPP has preloaded ssl certificate in php 7 packages
consider uncommon vhosts extra and place this in it
my only persistent issues is codeigniter 4 routes, have to turn on php spark serve to get XAMPP to route pages outside of default index, nothing else works, its garbage to that extent, will try with composer next....a whole book needs
to be wrote about codeigniter 4 routes and why they don't work, 200 pages plus
<VirtualHost localhost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
<VirtualHost example.com *:8080>
ServerName example.com
ServerAlias www.example.com
DocumentRoot "C:\xampp\htdocs\codeignite4\public"
//my project folder is codeignite4 without using composer this time
//i added listen 8080 under listen 80 in htppd.conf
ServerName example.com
<VirtualHost truservex.com *:443>
DocumentRoot "C:\xampp\htdocs\codeignite4\public"
ServerName example.com
SSLEngine On
SSLCertificateFile "C:/xampp/apache/conf/ssl.crt/server.crt"
// you can verifiy these file locations, certificate data
SSLCertificateKeyFile "C:/xampp/apache/conf/ssl.key/server.key"
// going without the Directory tag can be helpful to drop in vhosts
<Directory "C:\xampp\htdocs\codeignite4\public">
Require all granted
doing this i was able to replicate the original install, create site access
using http://localhost:8080 or http://example.com/ as my base url
in my example index.php is removed, set to ''
when using command prompt to get into codeignite4 project folder i can
launch php spark serve and routes will work that were previously 404
Using Xampp 7.3.25 Dec 2020 because php 8 will not run error
free with codeigniter 4 as of this date, this worked for me as
my first codeigniter 4 virtual host setup, my install had
difficulty initially with using port 80, seems to want to for
port 443 if it can..I'm not a server pro but i wanted to
leave this for the next guy....This is strictly name based
virtual hosts for develop, ip based would have obvious
advantages. Because i had trouble in initial CI4 testing with
port 80 the (*) in virtual hosts vs (*:80) seemed to solve one
hurdle in searching for more ports, now i can finally begin my
first project ...my default URL was also changed to example.com
in appstarter/apps/config file. Carefully reread <tags> for
typos, its easy to shut server down!
<VirtualHost *>
DocumentRoot "C:/Xampp/htdocs/"
ServerName localhost
<Directory "C:/Xampp/htdocs/">
Require all granted
<VirtualHost *>
DocumentRoot "C:/Xampp/htdocs/appstarter/public/"
ServerName example.com
ServerAlias www.example.com
# maybe don't attempt to use dir tag, shuts down server
# the directives at httpd.conf appear to suffice
I have added a htaccess file in the appstarter/public
I assume this is primitive, can get far more advanced
The Apache help pages helped me focus a bit more on
what i must accomplish, name based virtual hosts this case
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
2.2 Apache configuration: :Apache server context important!
Order allow,deny :The hackers are winning.....
Allow from all
2.4 Apache configuration:
Require all granted
I've been trying for a few hours to install Laravel 4 and make the Virtual Hosts and Routing work but so far I've been unlucky. I'm mentioning that I'm doing this on a Windows 7 machine and WAMP.
I'll describe what I've already done:
I've enabled rewrite_module.
Updated httpd-vhosts.conf with the following:
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/laravel/public"
ServerName laravel.dev
ServerAlias www.laravel.dev
</VirtualHost>
Next, I've set up the etc/hosts:
127.0.0.1 localhost
127.0.0.1 laravel.dev
Also, the following lines are uncommented both in wamp/../conf/httpd.conf and in wamp/.../conf/original/httpd.conf:
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Include conf/extra/httpd-vhosts.conf
The content of my .htaccess is the following:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Yet, when I go to http://laravel.dev I get an Internal Server Error - The server encountered an internal error or misconfiguration and was unable to complete your request..
If i remove the .htaccess file from the public folder, then I'll see the Laravel "You have arrived" message. If then, i create a route like this (within the app\routes.php):
Route::get('/newroute', function()
{
return View::make('hello');
});
and then go to http://laravel.dev/newroute I'll end up with a 404 Not Found - The requested URL /newroute was not found on this server.
I am seriously confused and have no idea how I can get past this. I mention (although i think it's clear) that I ran a composer install after cloning the project template, installing the dependencies.
If the htaccess file that you posted was in your /public/ folder, then that's why you're getting a 500 internal server error. That htaccess file was made for the folder that the /public/ folder is in. But since your public folder is the document root, you don't need it.
The htaccess file in the /public/ folder should look like this:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
(for WAMP).
Try turning on AllowOverride All on the directory by changing your VirtualHost to:
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/laravel/public"
ServerName laravel.dev
ServerAlias www.laravel.dev
<Directory "c:/wamp/www/laravel/public">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I have gone through the same issue and followed the all the treatments given above but virtual host can not be set.
When I inspected file http.conf then I found that inclusion of file httpd-vhosts.conf was commented as given below. Make sure to include httpd-vhosts.conf in httpd.conf.
#Include conf/extra/httpd-vhosts.conf
I have removed the # comment. Restarted the wamp and it was working.
Include conf/extra/httpd-vhosts.conf