我在文档根目录中创建了一个 .htaccess 文件/var/www/html/
重写 Codeigniter 的 URL,从所有页面的 URL 中删除“index.php”。
例如更改网址自
http://myhost/index.php/controller/function
to
http://myhost/controller/function`
这是我的`/var/www/html/.htaccess 的代码
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
我从谷歌搜索中得到了很多启用 mod-rewrite 模块的建议,但我可以在我的httpd.conf
它已经启用了。
LoadModule rewrite_module modules/mod_rewrite.so
这在我的 Debian 7 (Apache/2.4.4) 上运行的本地系统上完美运行。
任何帮助,将不胜感激。 :)
您还需要指定可以使用它的位置。例如,在 /etc/httpd/conf/httpd.conf 中,您应该看到类似以下内容:
<Directory "/var/www/html">
...lots of text...
</Directory>
确保有:
<Directory "/var/www/html">
AllowOverride All
</Directory>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)