【问题标题】:Codeigniter .htaccess redirectCodeigniter .htaccess 重定向
【发布时间】:2014-11-26 13:46:40
【问题描述】:

我不明白这是如何工作的,而后者则不行...如果我的 root 上有一个 .htaccess:

RewriteEngine on
RewriteBase /

ReWriteCond %{REQUEST_URI} !public/
ReWriteRule ^(.*)$ public/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php?/$0 [PT,L] 

当我输入我的 URL (localhost) 时,我在 root/public/index.php 中的索引一切正常。页面重定向找到我的索引并删除部分 URL。

但是,如果我将所有内容重新定位到另一个文件 root/en 并将 .htaccess 文件放入其中:

RewriteEngine on
RewriteBase /

ReWriteCond %{REQUEST_URI} !en/public/
ReWriteRule ^(.*)$ en/public/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php?/$0 [PT,L] 

当我输入 localhost/en 时,它不想再将我重定向到 root/en/public/index.php... 我得到“找不到您请求的页面。”

【问题讨论】:

  • 如果您删除 .htaccess 文件并尝试通过完整路径浏览到目录,codeigniter 是否会加载,还是会出现相同的错误? (localhost/en/public)

标签: php .htaccess codeigniter mod-rewrite


【解决方案1】:

尝试将 RewriteBase 设置为您放置应用程序的目录

RewriteEngine on   
RewriteBase /en

【讨论】:

  • 我收到内部服务器错误,这意味着我的 .htaccess 与当前设置有误
猜你喜欢
  • 2023-03-20
  • 1970-01-01
  • 2013-07-02
  • 2013-05-01
  • 1970-01-01
  • 2012-07-16
  • 2016-07-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多