我正在尝试为codeigniter项目创建一个虚拟主机。我在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>
并在application / config / config.php中,
$config['base_url'] = 'http://dev.facebook-login.com';
和
$config['index_page'] = '';
浏览器会打开着陆页。但是当从任何其他uri过境时,它说没有找到对象。 当我像这样配置httpd-vhosts.conf时:
<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>
它出现资产事物的问题,我,电子图像和一些CSS没有负载。我怎么解决呢? 请帮帮我。
答案 0 :(得分:2)
我在Windows 10上,我使用xampp和虚拟主机这是我设置的方式。
在基本网址末尾提出斜杠
$config['base_url'] = 'http://dev.facebook-login.com/';
首先转到
Windows&gt; System32&gt;司机&gt;等等&gt;主机强>
您可能需要以管理员身份打开才能保存
你可能会看到像
这样的东西127.0.0.1 localhost
在下面为dev.facebook-login.com创建另一个例如:
127.0.0.1 localhost
127.0.0.1 dev.facebook-login.com
保存
然后转到
xampp&gt; apache&gt; conf>额外&gt;的httpd-vhosts.conf 强>
以管理员身份打开它,以便保存。
不需要DocumentRoot上的index.php
<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>
保存并重新启动服务器。
我将此用于我的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]
答案 1 :(得分:0)
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>
答案 2 :(得分:0)
https://www.namecheap.com/support/knowledgebase/article.aspx/10026/33/installing-an-ssl-certificate-on-xampp/ 截至 2021 年 1 月,php 8 尚未为 CI4 做好准备! XAMPP 在 php 7 包中预装了 ssl 证书 额外考虑不常见的虚拟主机并将其放入其中 我唯一持续存在的问题是 codeigniter 4 路由,必须打开 php spark serve 才能让 XAMPP 路由默认索引之外的页面,没有其他工作,它的垃圾到了那个程度,接下来将尝试使用作曲家......一整本书都需要 写关于 codeigniter 4 路线以及为什么它们不起作用,200 页以上
<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
这样做我能够复制原始安装,创建站点访问 使用 http://localhost:8080 或 http://example.com/ 作为我的基本网址 在我的示例中 index.php 被删除,设置为 '' 使用命令提示符进入 codeignite4 项目文件夹时,我可以 启动 php spark serve 和路由将工作以前的 404
答案 3 :(得分:-1)
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!
<虚拟主机 *> DocumentRoot "C:/Xampp/htdocs/" 服务器名称本地主机 <目录“C:/Xampp/htdocs/”> 要求所有授予
<虚拟主机 *>
DocumentRoot "C:/Xampp/htdocs/appstarter/public/"
服务器名称 example.com
服务器别名 www.example.com
# 可能不要尝试使用 dir 标签,关闭服务器
# httpd.conf 中的指令似乎就足够了
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