【问题标题】:Codeigniter and mod_rewrite, rewrite not working and 404 errorCodeigniter 和 mod_rewrite,重写不起作用和 404 错误
【发布时间】: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

想不通:(

【问题讨论】:

标签: php apache .htaccess codeigniter mod-rewrite


【解决方案1】:

也许你只需要配置:

$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";

在这个网址中:

https://ellislab.com/codeigniter/user-guide/general/routing.html

你可以找到一些我认为会有所帮助的例子

【讨论】:

    猜你喜欢
    • 2014-07-14
    • 1970-01-01
    • 2013-11-23
    • 1970-01-01
    • 2012-12-09
    • 2013-05-05
    • 2011-06-21
    • 2013-05-31
    • 1970-01-01
    相关资源
    最近更新 更多