2

我在 codeigniter 中制作应用程序,现在上传到 GoDaddy 服务器但收到 404 错误。

我的代码是这样的

$config['index_page'] = "index.php?";
$config['uri_protocol'] = "QUERY_STRING";

.htaccess 文件是

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

我得到了像

http://yourdomain.com/index.php?controller/action/etc

但是我需要

http://yourdomain.com/controller/action/etc

请帮忙。

4

5 回答 5

0

谢谢大家的回答非常感谢,但正确的答案是这样的htaccess文件的代码是这样的

Options -Indexes
Options +FollowSymLinks
Options -MultiViews
DirectoryIndex index.php
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [NC,L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
  ErrorDocument 404 index.php
</IfModule>
于 2013-11-29T09:34:51.857 回答
0

试试这个......它应该工作。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sgu_portal
RewriteCond $1 ^(application|system|private|logs)
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
RewriteCond $1 ^(index\.php|css|js|images|img|less|player-skin|robots\.txt|opensearch\.xml|favicon\.ico|assets|forums)

输入您的文件夹 CSS,js,images 或其他。如果不是你的CSS不工作。

RewriteRule ^(.*)$ - [PT,L]
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>

在 CI 配置中

$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
于 2013-11-27T03:41:14.200 回答
0

参考这个答案

https://stackoverflow.com/a/16558169/1182195

确保您的服务器配置设置为

1. 启用模组重写

2. 允许在您的 apache 中覆盖 htaccess

于 2013-11-27T03:46:31.430 回答
0

尝试这个

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule> 
于 2013-11-14T07:05:56.330 回答
0

尝试

$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";
于 2013-11-14T07:31:41.843 回答