和朋友在做一个小网站,用到了CI框架,之前测试都是在windows上,隐藏index.php也相对比较简单。但服务器是ubuntu系统,需要配置一下,根据网上看到的一些教程,结合自己电脑的特点,记录步骤如下: 1.服务器环境: ubuntu12.04 64位 2. 开启mod_rewrite模块
和朋友在做一个小网站,用到了CI框架,之前测试都是在windows上,隐藏index.php也相对比较简单。但服务器是ubuntu系统,需要配置一下,根据网上看到的一些教程,结合自己电脑的特点,记录步骤如下:
1.服务器环境: ubuntu12.04 64位
2.开启mod_rewrite模块:
(1)将 /etc/apache2/mods-available/rewrite.load 连接到 /etc/apache2/mods-enabled/rewrite.load 来打开 Mod_rewrite 模块.
<span>sudo</span> <span>ln</span> -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
(2)修改 /etc/apache2/sites-enabled/000-default,将其中的:AllowOverride None 修改为:AllowOverride All,如下:
DocumentRoot /var/<span>www </span><directory></directory><span> Options FollowSymLinks AllowOverride All </span> <directory></directory><span> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </span>
重启apache2:
<span>sudo</span> service apache2 restart
3.在CI的根目录下,即在system的同级目录下,新建.htaccess文件:
<span>RewriteEngine on RewriteCond </span>%{REQUEST_FILENAME} !-<span>f RewriteCond </span>%{REQUEST_FILENAME} !-<span>d RewriteCond $</span><span>1</span> !^(index\.php|index\.html|images|<span>robots\.txt) RewriteRule </span>^(.*)$ /index.php/$<span>1</span> [L]
如果CI目录不是在www的根目录下,例如我的是:http://localhost/iter/index.php/,第四行需要改写为RewriteRule ^(.*)$ /iter/index.php/$1 [L]。
4.将CI中配置文件(system/application/config/config.php)中,将 $config['index_page'] = "index.php"; 中的index.php去掉。
//$config[<span>'</span><span>index_page</span><span>'</span>] = <span>"</span><span>index.php</span><span>"</span><span>; $config[</span><span>'</span><span>index_page</span><span>'</span>] = <span>""</span>; 。
大功告成,小伙伴试试看!!!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
