.htaccess
在项目根目录创建 .htaccess
,在其中填入如下代码:
AddDefaultCharset UTF-8 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] # 由于 Apache 默认过滤请求头中的 Authorization # 如果你准备做 JWT 的 API 服务,请加上这两行 RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] </IfModule>
Apache
打开你的 Apache 配置文件:Apache/conf/httpd.conf
。
1. 开启 mod_rewrite
:
2. 包含 httpd-vhosts.conf
:
3. 创建 VirtualHost
打开 Apache/conf/extra/httpd-vhost.conf
:
Nginx
HOSTS
如果你是 windows 的话,打开 C:\Windows\System32\drivers\ect\HOSTS
:
# acl.in.ci.com 对应 Apache 的 VirtualHost # 随意定义一个你喜欢的即可 127.0.0.1 acl.in.ci.com
CodeIngiter
打开 application/config/config.php
,将 $config['index_page']
至为空字符串:
访问项目
重启 Apache 后,在浏览器中输入上述中定义的 HOSTS:acl.in.ci.com