【问题标题】:Pretty URL’s and mod_rewrite漂亮的 URL 和 mod_rewrite
【发布时间】:2011-03-09 07:53:13
【问题描述】:

我似乎无法完成这项工作 - 我很确定真正的问题是我只是让自己盲目地主演,所以我希望一双新鲜的眼睛可以帮助我。

我不想在我的系统上附加多个应用程序。 此时,根文件夹中已经存在一个网站,但我不想在 CI 安装中使用一些 microsites/powerformats。

我的 mod_rewrite 看起来像这样:

RewriteCond %{REQUEST_URI} ^/(powerformat1|powerformat2)/?$
RewriteRule ^(.*)$ powerformats/index.php/$1 [L] 

尽管正确获取 CI index.php,但在尝试访问 example.org/powerformat1 或 example.org/powerformat2 时,我会看到 CI 的 404 页面。

似乎无论我尝试重写规则,我要么得到 404 页面,要么什么都没有。

有什么见解吗?

-- 编辑--

我认为我的问题是 CI 实际上将“powerformat1”字符串作为第一段传递。这是我需要避免的。但是这不能通过 mod_rewrite 解决吗?

【问题讨论】:

  • 第一步:检查你的日志,里面肯定有关于重写的内容。
  • @Berry - 我做到了。我得到的只是:192.168.10.175 - - [09/Mar/2011:09:04:06 +0100] "GET /powerformat1 HTTP/1.1" 404 539;我仍然验证(通过 404 页面的外观)我确实获得了 CI 代码。

标签: php apache codeigniter mod-rewrite


【解决方案1】:

您可以尝试使用适当的查询字符串直接链接到文件

RewriteRule ^(.*)$ /powerformats/index.php?somequery=$1 [L]
(您可能需要更改斜线,见下文)

或者可能是这样的:

访问/powerformat1/ 可能正在重写到
powerformats/index.php//powerformat1/

你可以试试
RewriteRule ^/(.*)/$ /powerformats/index.php/$1 [L]
或其他带有斜线的变体:
RewriteRule ^/(.*)/$ /powerformats/index.php/$1/ [L]

【讨论】:

    【解决方案2】:

    你错过了RewriteEngine On 吗?

    【讨论】:

      猜你喜欢
      • 2011-08-11
      • 1970-01-01
      • 2011-03-09
      • 1970-01-01
      • 2011-02-04
      • 1970-01-01
      • 1970-01-01
      • 2012-05-28
      • 2010-11-01
      相关资源
      最近更新 更多