问题描述
我正在尝试为codeigniter项目创建虚拟主机.我已经在httpd-vhosts.conf中完成了此操作:
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>
以及在application/config/config.php中,
and in application/config/config.php,
$config['base_url'] = 'http://dev.facebook-login.com';
和
$config['index_page'] = '';
浏览器打开登录页面.但是从其他任何uri转换时,都表示未找到对象.当我像这样配置httpd-vhosts.conf时:
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>
出现资产问题,即图像和某些CSS无法加载的问题.我该如何解决?请帮助我.
It arises problem with assets things, i,e images and some css doesnt loads. How can i solve it?Please help me.
推荐答案
我在Windows 10上,并且将xampp与虚拟主机一起使用,这是我设置的方式.
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/';
首先进入
您可能需要以管理员身份打开才能保存它
You may need to open as administrator to be able to save it
您可能会看到类似的东西
You might see some thing like
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 dev.facebook-login.com
保存
然后转到
以管理员身份打开它,以便您保存它.
open it as administrator so you can save it.
不需要DocumentRoot上的index.php
No need for the index.php on DocumentRoot
<VirtualHost *:80>
##ServerAdmin [email protected]
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
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]
这篇关于如何为codeigniter项目完美设置虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!