codeigniter的URL重写问题重写、问题、codeigniter、URL

由网友(灰色年华)分享简介:我用下面的的htaccess 脚本,这样我可以隐藏的的index.php 在 URI I’ve using the following htaccess script so that i can hide index.php from the uri.RewriteEngine onRewriteCond $1...

我用下面的的htaccess 脚本,这样我可以隐藏的的index.php 在 URI

I’ve using the following htaccess script so that i can hide index.php from the uri.

RewriteEngine on
RewriteCond $1 !^(index.php|resources|assets|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

但我面临的主要问题:(

But i’ve facing a major problem :(

我有一个名为资产我旁边的的index.php 文件目录,它应该在那里。 现在,当我浏览目录由浏览器那么codeigniter的未找到页显示。 我不能浏览文件的 /assets/image.jpg ,但它显示,当我从&LT叫它; IMG> 标记

I’ve a directory named assets beside my index.php file and it should be there. Now when i browse the directory by browser then the codeigniter’s not found page displays. I can’t browser the file /assets/image.jpg but it displays when i call it from an <img> tag

现在我该怎么办?

请注意,这是工作在我的本地服务器(本地),但不是在活的服务器。

Note that it is working in my local server (localhost) but not in the live server.

推荐答案

你们是一路过来想这一点。

You guys are way over thinking this.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*)$ /index.php/$1 [NC,L]

这将传递阿帕奇将不利于脱至codeIgniter任何请求。这样,你可以自由各地创建目录没有更新您的重写规则,你不需要设置404处理在Apache中(甚至在图像/资源目录)。

That'll pass any request that Apache wouldn't serve off to CodeIgniter. This way you're free to create directories all over without updating your rewrite rules, and you don't need to setup 404 handling in Apache (even inside your image/resource directories).

幸得Zend框架笔者推荐在他们的用户指南该位。这一版本稍微修改为codeIgniter。

Credit goes to the Zend Framework authors that recommend this bit in their user guide. This version is slightly modified for CodeIgniter.

阅读全文

相关推荐

最新文章