简体   繁体   English

Codeigniter url /具有模式重写htacess的链接:未找到对象

[英]Codeigniter url/links with mode rewrite htacess: object not found

I am working on project using codeigniter for the first time with bootstrap 3. 我第一次在Bootstrap 3中使用Codeigniter进行项目。

My application and system folder from CI is located outside my 'project.main' folder. 我来自CI的应用程序和系统文件夹位于我的“ project.main”文件夹之外。 Everything works fine until I try to use .htaccess in my project. 一切正常,直到我尝试在项目中使用.htaccess。

I am using an XAMPP server and I already loaded the rewrite module and as well as the AllowOverride All and restarted my server. 我正在使用XAMPP服务器,并且已经加载了重写模块和AllowOverride All,并重新启动了服务器。
My url now looks like this ' http://localhost/project.main/ ' .. 我的网址现在看起来像这样' http://localhost/project.main/ '..
Now my question is since I already removed the 'index.php', my navbar links in bootstrap was like this 现在我的问题是,因为我已经删除了“ index.php”,所以我在引导程序中的导航栏链接是这样的
' <a href='<?php echo site_url("pages/view/about"); ?> ' <a href='<?php echo site_url("pages/view/about"); ?> <a href='<?php echo site_url("pages/view/about"); ?>
but if I click it I am directed to the url 但是如果我单击它,我将定向到该URL
' http://localhost/project.main/pages/view/about ' which gives me ' http://localhost/project.main/pages/view/about '这给了我

Object not found' error page. 找不到对象”错误页面。

But if I use href=' <?php echo site_url("index.php/pages/view/about"); ?> 但是,如果我使用href=' <?php echo site_url("index.php/pages/view/about"); ?> href=' <?php echo site_url("index.php/pages/view/about"); ?> I am routed to the right page. href=' <?php echo site_url("index.php/pages/view/about"); ?>我被路由到正确的页面。 Which is the right way of doing it? 哪种方法正确? and under my config.php I have this $config['uri_protocol'] = 'REQUEST_URI '; 在我的config.php下,我有这个$config['uri_protocol'] = 'REQUEST_URI '; is it necessary that uri_protocol match what is on the .htaccess under RewriteCond %(REQUEST_URI).. ? uri_protocol是否必须与RewriteCond %(REQUEST_URI)..下.htaccess上的uri_protocol匹配RewriteCond %(REQUEST_URI)..
What i read in github there are two versions of .htaccess. 我在github中阅读的内容有.htaccess的两个版本。

You didnt mention changing index page to blank inside config.php ? 您没有提到将config.php内的索引页更改为空白吗? In case of emergency I give you my simple htaccess. 紧急情况下,我给您简单的htaccess。 It works when moving application and system folders out of public. 将应用程序和系统文件夹移出公共场所时,它可以工作。

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Also try to switch uri_protocol option. 也尝试切换uri_protocol选项。

Here's the ultimate solution for index.php How to remove "index.php" in codeigniter's path . 这是index.php的最终解决方案。 如何在codeigniter的路径中删除“ index.php”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM