codeigniter 问题 - 迁移后站点重定向到本地主机

发布于 2024-11-08 22:32:58 字数 886 浏览 0 评论 0原文

我刚刚将 CI 文件从服务器复制到本地主机,但运行该网站时遇到问题。

每当我点击 WAMP 中的站点链接时 http://localhost/CmpOnline/

它显示了与本地主机相同的文件夹列表,

这是我的 htaccess 文件

RewriteEngine on
RewriteCond $1 !^(index\.php|images|javascript|stylesheets|uploads|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

,在配置文件

$config['base_url'] = "http://localhost/CmpOnline/";

$config['index_page'] = "";

$config['uri_protocol'] = "REQUEST_URI";

我将其更改为所有其他可用选项,但它仍然不起作用

我尝试了这个 .htaccess 和 codeigniter 不工作 还有这个 从 URL 中删除 index.php - Codeigniter 2

但它仍然没有工作。

有什么帮助吗?

i just copied the CI files from server to my localhost and I am having problem running the site.

Whenever i click the site link in WAMP
http://localhost/CmpOnline/

it shows me the same folderlist as on localhost

this is my htaccess file

RewriteEngine on
RewriteCond $1 !^(index\.php|images|javascript|stylesheets|uploads|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

and in the config file

$config['base_url'] = "http://localhost/CmpOnline/";

$config['index_page'] = "";

$config['uri_protocol'] = "REQUEST_URI";

I changes this to all the other available options but it still does not work

I tried this
.htaccess and codeigniter not working
and this
Remove index.php From URL - Codeigniter 2

But it still does not work.

Any help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

简单 2024-11-15 22:32:58

您应该有一个 RewriteBase

RewriteEngine on
RewriteBase /CmpOnline
RewriteCond $1 !^(index\.php|images|javascript|stylesheets|uploads|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

因为 RewriteRule 将所有内容发送到 RewriteBase 的根目录,默认为 / (CodeIgniter 仍然需要 base_url 设置,用于其内部内容)。

You should have a RewriteBase:

RewriteEngine on
RewriteBase /CmpOnline
RewriteCond $1 !^(index\.php|images|javascript|stylesheets|uploads|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

since the RewriteRule is sending everything to the root of RewriteBase, which defaults to / (CodeIgniter will still need the base_url setting, for its internal stuff).

不打扰别人 2024-11-15 22:32:58

如果

$config['uri_protocol'] = "REQUEST_URI";

将其更改为

$config['uri_protocol'] = 'PATH_INFO';

如果将其

$config['uri_protocol'] = 'ORIG_PATH_INFO';

与重定向或标头位置一起使用到不在 htaccess 中的 url 将不起作用,则必须在 htaccess 中添加 url 才能工作

if

$config['uri_protocol'] = "REQUEST_URI";

change it to

$config['uri_protocol'] = 'PATH_INFO';

if use this

$config['uri_protocol'] = 'ORIG_PATH_INFO';

with redirect or header location to url not in htaccess will not work you must add the url in htaccess to work

七颜 2024-11-15 22:32:58
Options +FollowSymLinks
RewriteEngine on

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

Options +FollowSymLinks
RewriteEngine on

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文