【发布时间】:2014-10-20 18:11:44
【问题描述】:
我对 CodeIgniter 和 mod_rewrite 模块有疑问。 在 Apache 中,我遵循了我在 ellislab 博客中找到的所有说明。所以删除 index.php 也可以。现在我有了这个文件 .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteBase /
#RewriteRule ^box/$ create/$1 # Handle requests for "pet-care"
RewriteRule ^about/$ aboutus
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
# In caso di mancanza di installazione del modulo mod_rewrite,
# tutte le pagine 404 possono essere inviate ad index.php
# e tutto funzionera' normalmente
ErrorDocument 404 /index.php
</IfModule>
我不能去工作的是线路
#RewriteRule ^about/$ aboutus
我想在 localhost/about 中重写我的 localhost/aboutus。我有一个名为 aboutus 的控制器,它引用关于我们的视图。
另一个问题是当我有这样的 url 结构时:
localhost/controller/function/param1/param2
我想转换成:
localhost/myname/param1
想不通:(
【问题讨论】:
-
您应该使用
config/route.php来路由此类uri以获取更多信息ellislab.com/codeigniter/user-guide/general/routing.html -
谢谢,这很好用!!! :)
标签: php apache .htaccess codeigniter mod-rewrite