[英]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我正在使用 XAMPP v3.2.4,我不知道这是否有什么区别,但 Joomla 3.9.14
In my local environment I access my Joomla site by visiting localhost/mysite
.在我的本地环境中,我通过访问
localhost/mysite
来访问我的 Joomla 站点。 I now want to have a sub domain localhost/apps.mysite
.我现在想要一个子域
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
.我创建了一个名为
apps
的文件夹并将其放在我的 Joomla 根目录中,即C:\\xampp\\htdocs\\mysite\\apps
。 This folder contains a single index.html
file.该文件夹包含一个
index.html
文件。
I've made the following changes;我进行了以下更改;
In my Windows hosts
file I added the following line;在我的 Windows
hosts
文件中,我添加了以下行;
127.0.0.1 localhost/apps.mysite
In my httpd-vhosts.conf
file I added;在我添加的
httpd-vhosts.conf
文件中;
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.
我已经重新启动了几次 Apache,没有任何变化。
When I visit the URL http://localhost/apps.mysite
I see the following error;当我访问 URL
http://localhost/apps.mysite
我看到以下错误;
Object not found!
未找到对象! The requested URL was not found on this server.
在此服务器上找不到请求的 URL。 If you entered the URL manually please check your spelling and try again.
如果您手动输入了 URL,请检查您的拼写并重试。
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
错误 404 本地主机 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
为了在
http://localhost/apps.mysite
访问我的子域,我需要更改什么
Start by creating a VirtualHost for localhost in case you want to use that for a bit of fiddling首先为 localhost 创建一个 VirtualHost,以防你想用它来做一些小玩意
# 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您需要像这样将这 2 个站点添加到
C:\\windows\\system32\\drivers\\etc\\hosts
文件中
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对于 HOSTS 文件的更改,您将需要从命令窗口重新启动或刷新 DNS 缓存,如下所示
>ipconfig /flushdns
First host file does not handle folders, just map IP addresses to hostname.第一个主机文件不处理文件夹,只是将 IP 地址映射到主机名。
Host file should be主机文件应该是
127.0.0.1 localhost apps.mysite
or或者
127.0.0.1 localhost
127.0.0.1 apps.mysite
I prefer the second method because I can comment the line..我更喜欢第二种方法,因为我可以评论该行..
Second Your virtual host ServerName localhost/apps.mysite does not work with sub folders.第二,您的虚拟主机ServerName localhost/apps.mysite不适用于子文件夹。
Valid Servername values can be: domain.com, example.com, site1.example.com, user.site1.example.com and son on.有效的 Servername 值可以是:domain.com、example.com、site1.example.com、user.site1.example.com 等等。
A virtual host example to map the apps.mysite should be:映射 apps.mysite 的虚拟主机示例应该是:
<VirtualHost *:80>
ServerName apps.mysite
ServerAlias www.apps.mysite
## Vhost Document Root
DocumentRoot "C:/xampp/htdocs/mysite/apps"
</VirtualHost>
This is a minimal example, no logs defined or directory specific rules.这是一个最小的例子,没有定义日志或特定于目录的规则。 With this configuration you will be able to reach your site by using http://apps.mysite only on your computer because the host file is resolving the "apps.mysite" to your localhost (127.0.0.1).
使用此配置,您将能够仅在您的计算机上使用http://apps.mysite访问您的站点,因为主机文件将“apps.mysite”解析为您的本地主机 (127.0.0.1)。
What do I need to change in order to access my subdomain at http://localhost/apps.mysite
为了在http://localhost/apps.mysite访问我的子域,我需要更改什么
http://localhost/apps.mysite is not a sub-domain is a domain localhost with a folder apps.mysite, a valid subdomain is subDomain.domain.com. http://localhost/apps.mysite不是子域是带有文件夹 apps.mysite 的域 localhost,有效的子域是 subDomain.domain.com。
.com is a top level domain .com是顶级域名
domain.com is a domain name domain.com是一个域名
subDomain.domain.com is a subdomain of domain.com subDomain.domain.com是 domain.com 的子域
Hope it helps.希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.