【问题标题】:CodeIgniter local htaccessCodeIgniter 本地 htaccess
【发布时间】:2014-04-06 08:17:12
【问题描述】:

我创建了一个使用 CI 和主题的小型站点(仅内容更改)。在第一次运行时,它运行良好,但是当我单击另一个链接时,视图会发生变化,但 url 不会。这是我的 .htaccess 内容 `

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine on
  RewriteBase /CodeIgniter_2.1.4/
  RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /CodeIgniter_2.1.4/index.php?/$1 [L]
</IfModule>

`

在我的配置中:

$config['base_url'] = 'http://localhost/CodeIgniter_2.1.4/'; $config['index_page'] = '';

这是我的路线的内容:

$route['default_controller'] = "welcome"; $route['test'] = 'welcome/test';

这是我的链接:&lt;a href="test"&gt;Contact&lt;/a&gt;

有人可以帮助我吗?提前致谢 (对不起我的英语不好:))

【问题讨论】:

  • 你能检查一下吗 - $config['uri_protocol'] = 'AUTO';
  • 您能否检查一下 - 选项 +FollowSymlinks RewriteEngine on RewriteBase /CodeIgniter_2.1.4/ RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !- f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA]
  • 还是一样的结果,视图改变了但url没有改变
  • 你能检查一下这个 - $config['uri_protocol'] = 'REQUEST_URI';
  • 我得到一个 500 状态码

标签: php .htaccess codeigniter mod-rewrite


【解决方案1】:

请看下面,它在我的本地主机上工作

config.php
=======================
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';
$config['language'] = 'english';
$config['charset'] = 'UTF-8';


.httacces
=======================

#Initialize mod_rewrite
RewriteEngine On

# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/
RewriteBase /CodeIgniter_2.1.4/

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


#For reuests that are not actual files or directories,
#Rewrite to index.php/URL
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ /%1 [R=301,L]

【讨论】:

  • 我的视图完全改变了,但 url 没有改变。它仍然在浏览器中显示基本 url
  • 它有效。问题是由于angularjs。当我从我的页面中删除 ng-app 时,它可以工作。
猜你喜欢
  • 2015-08-08
  • 2018-08-30
  • 1970-01-01
  • 2012-05-16
  • 2023-03-29
  • 1970-01-01
  • 2017-09-09
  • 2011-06-01
  • 2014-03-08
相关资源
最近更新 更多