php - XAMPP Subdomain with Joomla Site
问题描述
I'm using XAMPP v3.2.4 and I don't know if this makes any difference but Joomla 3.9.14
In my local environment I access my Joomla site by visiting localhost/mysite
. I now want to have a sub domain localhost/apps.mysite
.
I've created a folder called apps
and placed this in my Joomla root directory, which is C:\xampp\htdocs\mysite\apps
. This folder contains a single index.html
file.
I've made the following changes;
In my Windows hosts
file I added the following line;
127.0.0.1 localhost/apps.mysite
In my httpd-vhosts.conf
file I added;
NameVirtualHost 127.0.0.1:80
<virtualhost *:80="">
DocumentRoot "C:/xampp/htdocs/mysite/apps"
ServerName localhost/apps.mysite
ServerAlias www.apps.mysite.localhost.com
</virtualhost>
I haven't made any other changes to config files. I've restarted Apache a few times, no change.
When I visit the URL http://localhost/apps.mysite
I see the following error;
Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404 localhost Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.3.9
What do I need to change in order to access my subdomain at http://localhost/apps.mysite
解决方案
Start by creating a VirtualHost for localhost in case you want to use that for a bit of fiddling
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs"/>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
## then add main site
<VirtualHost *:80>
ServerName mysite.local
ServerAlias www.mysite.local
DocumentRoot "C:/xampp/htdocs/mysite/"
<Directory "C:/xampp/htdocs/mysite/"/>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
## then add the sub domain
<VirtualHost *:80>
ServerName aps.mysite.local
ServerAlias www.aps.mysite.local
DocumentRoot "C:/xampp/htdocs/mysiteapps/"
<Directory "C:/xampp/htdocs/mysiteapps/"/>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
You will need to add these 2 sites to your C:\windows\system32\drivers\etc\hosts
file like this
127.0.0.1 mysite.local aps.mysite.local
::1 mysite.local aps.mysite.local
For the change to the HOSTS file you will either need to reboot or refresh the DNS Cache like this from a command window
>ipconfig /flushdns
推荐阅读
- swiftui - SwiftUI 视图中的 onReceive 导致无限循环
- search - 智能搜索索引问题 – Kentico 9
- javascript - 如何调用特定的cookie是JS
- apache - apache2.4中通配符子域的virtualhost通配符子域
- wordpress - 购物车和结帐页面的背景颜色
- python - SQLAlchemys .first() 和 .fetchone() 之间的区别
- c++ - 从 YouTube 复制的 OpenGL 着色器中的语法错误
- java - 模型视图视图模型结构
- ios - Swift SFSafariViewController 目前显示空白页
- swift - 为什么我不能在按钮中调用可变函数