带有 mod_rewrite htaccess 的 Codeigniter url/links:找不到对象
Codeigniter url/links with mode rewrite htacess: object not found
我第一次使用 codeigniter 进行项目 bootstrap 3.
我在 CI 中的应用程序和系统文件夹位于我的 'project.main' 文件夹之外。一切正常,直到我尝试在我的项目中使用 .htaccess。
我正在使用 XAMPP 服务器并且我已经加载了重写模块以及 AllowOverride All 并重新启动了我的服务器。
我的 url 现在看起来像这样 'http://localhost/project.main/' ..
现在我的问题是因为我已经删除了 'index.php',我在 bootstrap 中的导航栏链接是这样的
'<a href='<?php echo site_url("pages/view/about"); ?>
但如果我点击它,我将被定向到 url
'http://localhost/project.main/pages/view/about' 这给了我
Object not found' error page.
但是,如果我使用 href=' <?php echo site_url("index.php/pages/view/about"); ?>
,我会转到正确的页面。
哪种方法是正确的?在我的 config.php 下,我有这个 $config['uri_protocol'] = 'REQUEST_URI ';
是否有必要 uri_protocol
匹配 RewriteCond %(REQUEST_URI)..
下的 .htaccess 上的内容?
我在 github 中读到的内容有两个版本的 .htaccess。
您没有提到在 config.php 中将索引页更改为空白?在紧急情况下,我给你我的简单 htaccess。将应用程序和系统文件夹移出 public.
时有效
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]
也尝试切换 uri_protocol 选项。
这是 index.php How to remove "index.php" in codeigniter's path 的最终解决方案。
我第一次使用 codeigniter 进行项目 bootstrap 3.
我在 CI 中的应用程序和系统文件夹位于我的 'project.main' 文件夹之外。一切正常,直到我尝试在我的项目中使用 .htaccess。
我正在使用 XAMPP 服务器并且我已经加载了重写模块以及 AllowOverride All 并重新启动了我的服务器。
我的 url 现在看起来像这样 'http://localhost/project.main/' ..
现在我的问题是因为我已经删除了 'index.php',我在 bootstrap 中的导航栏链接是这样的
'<a href='<?php echo site_url("pages/view/about"); ?>
但如果我点击它,我将被定向到 url
'http://localhost/project.main/pages/view/about' 这给了我
Object not found' error page.
但是,如果我使用 href=' <?php echo site_url("index.php/pages/view/about"); ?>
,我会转到正确的页面。
哪种方法是正确的?在我的 config.php 下,我有这个 $config['uri_protocol'] = 'REQUEST_URI ';
是否有必要 uri_protocol
匹配 RewriteCond %(REQUEST_URI)..
下的 .htaccess 上的内容?
我在 github 中读到的内容有两个版本的 .htaccess。
您没有提到在 config.php 中将索引页更改为空白?在紧急情况下,我给你我的简单 htaccess。将应用程序和系统文件夹移出 public.
时有效RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]
也尝试切换 uri_protocol 选项。
这是 index.php How to remove "index.php" in codeigniter's path 的最终解决方案。