I want to change my localhost project URL as:
http://localhost/project_directory to http://project_directory.localhost
and http://localhost/project_directory/backend to http://backend.project_directory.localhost
Can you help me someone how to write rule in .htaccess?
You can create a virtual host in Apache.
<VirtualHost *:80>
ServerName project_directory.localhost
DocumentRoot "C:/public_html/project_directory"
</VirtualHost>
And add this line to your hosts file:
127.0.0.0 project_directory.localhost
Your hosts file is located in: C:\Windows\System32\drivers\etc
Edit the hosts file with Administrator rights.
Related
I am facing a minor problem while setting up vhost in xampp os - windows. here is the httpd-vhosts.conf in C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/yiisite/basic/web/"
ServerName yiisite
and in hosts file located C:\Windows\System32\drivers\etc\hosts
127.0.0.1 yiisite
so when i hit i get http://yiisite i get what i want, but all other folders inside htdocs that i use to open in localhost/abc is all going to yiisite template 404 not found . cannot access other projects inside htdocs with localhost . if i change the port in vhosts.conf i can access localhost/abc but not yiisite
changing the httpd-vhosts.conf to
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:/xampp/htdocs/yiisite/basic/web/"
ServerName yiisite
</VirtualHost>
solved the issue of conflicting with other projects inside htdocs and can access with localhost/otherproject
I am finding the following problem trying to create a vhost for a PHP website that I have into XAMPP.
So basically this is where is the index.php file of my website is deployed: C:\xampp\htdocs\MyProject-Panda
Then into the C:\xampp\apache\conf\extra\httpd-vhosts.conf** file I have declared 2 vhost:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/HotelRegistration/public"
ServerName laravel.dev
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/MyProject-Panda"
ServerName panda.dev
</VirtualHost>
(the first one works fine, the second one no).
Finally into the C:\Windows\System32\drivers\etc\hosts file I have:
127.0.0.1 localhost
127.0.0.1 laravel.dev
127.0.0.1 panda.dev
So I am enabling the panda.dev domain on my local machine.
The problem is that when I open the panda.dev domain into my browser it is automatically "rewrited" into http://www.panda.dev/ and it says that can't contact the server.
Why? What could be the problem? How can I try to solve this situation?
You should use .local for local sites. .dev must not be interpreted correctly by browsers, even if you have hosts record.
In this case I think problem is - you have some .htaceess in C:/xampp/htdocs/MyProject-Panda with redirect to WWW version. Windows hosts does not work for subdomains automaticly (as www.panda.dev is subdomain of panda.dev). You eighter has to remove this redirection or add 127.0.0.1 www.panda.dev record to your hosts file.
Requirement is to create two website
www.example1.com
www.example2.com
with the same codebase and database without copying it to another directory or importing the sql file.
Is it possible through just pointing it based on domain name and using .htaccess file.
Any help or hints is appreciated.
Yes you can. Start by placing all of your project files on the same directory, for the sake of this example let's call it /var/www/example
Then go to /etc/apache2/sites-available and create two .conf files:
example1.conf: Virtual Host Configuration for www.example1.com
example2.conf: Virtual Host Configuration for www.example2.com
The contents of the two configuration files:
example1.conf
<VirtualHost *:80>
DocumentRoot "/var/www/example"
ServerName www.example1.com
</VirtualHost>
exampl2.conf
<VirtualHost *:80>
DocumentRoot "/var/www/example"
ServerName www.example2.com
</VirtualHost>
As you can see both of them refer the same directory as Document Root but listen to different URLs.
After you're done creating those files don't forget to run the following commands on your terminal:
a2ensite example1.conf
a2ensite example2.conf
and finally,
service apache2 reload
I have two installations of laravel. One in a folder called "laravel" and the second in a folder called "learningLaravel". Both of them are siblings in the same parent folder. Before i installed "learningLaravel" i used to access the site in "laravel" through localhost/laravel/public, and everything works fine .
After i installed "learningLaravel", i decided to create a virtual host for it on my WAMP server with the name "learningLaravel.dev" . My [windows/system32/drivers/etc/hosts] file looks like this:
127.0.0.1 localhost
127.0.0.1 localhost
// I added this entry. The first two entries above was already there
127.0.0.1 learninglaravel.dev
I added the following to my Apache "httpd-vhosts.conf"::
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/learningLaravel/public"
ServerName learningLaravel.dev
</VirtualHost>
Now i can access "learningLaravel" through learningLaravel.dev. But when i want to access the site in the "laravel" folder through localhost/laravel/public, i get a message ::
Not Found
The requested URL /laravel/public was not found on this server.
I try localhost also and i get ::
Not Found
The requested URL / was not found on this server.
The problem i have now is anything that begins with localhost doesn't work, but learningLaravel.dev works.
What changes do i need to make? thanks.
Just define 2 virtual hosts:
The first catches all domains which don't have their own virtual host. In this example these are domain1.dev, domain2.dev, domain3.dev and localhost.
The second host catches the domain learninglaravel.dev
httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/"
ServerName localhost
ServerAlias *.localhost
</VirtualHost>
<VirtualHost learninglaravel.dev:80>
DocumentRoot "c:/wamp/www/learningLaravel/public"
ServerName learninglaravel.dev
ServerAlias *.learninglaravel.dev
</VirtualHost>
windows/system32/drivers/etc/hosts
127.0.0.1 learninglaravel.dev
# you don't need the following this is just for explanation:
127.0.0.1 domain1.dev
127.0.0.1 domain2.dev
127.0.0.1 domain3.dev
I am very new to magento and php and i am trying to create a virtual host url for my magento site.
Currently the url is
http://localhost:8080/Magento/
And if i create any website i have to use url's such as below
http://localhost:8080/Magento/website1
http://localhost:8080/Magento/website2
...
After referring to several examples such as this http://sawmac.com/xampp/virtualhosts/ i have managed to configure my files such as below
Step 1:
In the file C:\Windows\System32\drivers\etc\hosts i have append the below mapping
127.0.0.1 clientA.local
Step 2:
And in the file C:\xampp\apache\conf\extra\httpd-vhosts.conf i have append the below code
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "C:\xampp\htdocs\magento"
ServerName clientA.local
<Directory "C:\xampp\htdocs\magento">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
After step 1 typing typing clientA.local:8080/magento opens localhost:8080/magento
But step 2 doesn't change anything.
I want to do something as below
clientA.local should open http://localhost:8080/Magento/website1
clientB.local should open http://localhost:8080/Magento/website2
...
I have tried changing the Document root , directory in several ways nothing helped.
If any one has any idea on this senario please contribute here.
thanx