codeIginter,mod_rewrite的网址上和.htaccess网址、codeIginter、mod_rewrite、htaccess

2023-09-02 01:00:18 作者:殇情

我不能确定它的stackexchange网站是最适合这个问题,因为我可以看到它在几个配件,特别是取决于最终的答案。

I'm unsure of which stackexchange site is best suited for this question as I could see it fitting in to several, especially depending on the ultimate answer.

我现在面临的挑战是,我已经写了使用codeIgniter网站。该网站是一个相当简单的公司网站。我用codeIginter实施清洁的网址,并扩大该网站在未来的能力。还有一个简单的博客和画廊这两者都是动态的,由数据库驱动的。

The challenge I'm facing is that I've written a site using CodeIgniter. The site is a fairly simple company site. I've used CodeIginter to implement clean urls and the ability to expand the site in the future. There is also a simple blog and "gallery" which are both dynamic, driven by a database.

在我的开发环境,该网站的伟大工程。在我的网站(用于驱动我的话,preSS博客)临时空间,该网站也适用。

In my development environment, the site works great. On my staging space for the site (which drive my wordpress blog), the site also works.

现在的问题是因为我想要的网站移动到生产服务器,它停止工作。我已经能够得到的主页了(它使用数据库和资产),所以我相当肯定这些都是工作的权利。我已经将问题范围缩小到两种可能的配置问题或mod_rewrite的问题。

The problem is as I'm trying to move the site to the production server, it stops working. I've been able to get the home page up (which uses the database and assets) so I'm fairly sure those are all working right. I've narrowed the problem down to either possible configuration issues or mod_rewrite issues.

首先我必须带上了(但我不确定如何真正相关的,这是)是服务器使用CGI / FastCGI的,而我的发展和分期服务器使用阿帕奇2.0处理程序。请问这种差异的原因我需要修改我的.htaccess文件?我张贴的基本文件,在我的开发/舞台环境在这里工作的:

The first thing I must bring up (but I'm unsure of how truly relevant this is) is the server uses CGI/FastCGI whereas my development and staging servers use "Apache 2.0 Handler". Will this difference cause me to need to modify my .htaccess file? I'm posting the base file that works in my development/staging environments here:

RewriteEngine on
RewriteCond $1 !^(index.php|phpinfo.php|images|robots.txt|sitemap.xml.gz|sitemap.xml|assets)
RewriteRule ^(.*)$ /index.php/$1 [L]

这是pretty的直线前进。

It's pretty straight forward.

当我尝试运行在生产服务器上的网站,这个.htaccess文件,我得到:

When I attempt to run the site on the production server, with this .htaccess file, I get:

无法执行的是请求的脚本   [/ufs/websites/c/[redacted]/html/index.php/]:不是一个目录

Can not exec the requested script [/ufs/websites/c/[redacted]/html/index.php/]: Not a directory

当我改变我的.htaccess:

When I change my .htaccess to:

RewriteEngine on

RewriteBase /
RewriteCond $1 !^(index.php|images|robots.txt|sitemap.xml.gz|sitemap.xml|assets)

RewriteRule ^html/(.*)$ /index.php/$1 [L]  #This WILL Present the home page correctly whereas it used to give an error

这会给我的主页,但仍没有任何其他网页正常工作;相反,我会得到无论是404还是一个空白页。

It'll give me the home page, but still none of the other pages work; instead I'll get either a 404 or a blank page.

有关从目前来看,我猜这个问题是我重写规则,但我真的不能完全肯定。这可能是我的配置设置。我将继续闲逛,但我希望有人会都有这样的经历在以前的工作,可以帮助指明了正确的方向(或最佳还)告诉我,我做错了。 :-)

For the time being, my guess at the problem is my RewriteRule but I'm really not entirely sure. It could be a setting in my config. I'll continue to poke around but I'm hoping someone will have experienced this in prior work that could help point me in the right direction (or best-yet) tell me what I'm doing wrong. :-)

谢谢大家。

推荐答案

那么,你会看到这个问题问一千遍在原来的论坛。而this帖子也有类似的情况,每一个学尝试删除的index.php可挑剔:)查看额外的配置,你可以在该职位尝试。

Well, you will see this question asked thousand times in the original forums. And this post have similar situation where every attemp to remove index.php can be nitpicky :) See the additional configuration you can try in that post.