简体   繁体   中英

CodeIgniter URL Rewrite Issue

I am making application in codeigniter and now uploading to GoDaddy server but getting 404 error.

My code is like this

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

.htaccess file is

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

I am getting value like

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

But i need

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

Please help.

try this

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule> 

Try

$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";

Try this... it should work.

<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)

input your folder CSS,js,images or else. If not your css not working.

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

and in CI Config

$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

refer this answer

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

make sure that your server configuration is set to

1 . Enabled mod rewrite

2 . Allow overriding htaccess in your apache

Thank you all for answer Thank you so much but correct answer is like this code of htaccess file is like this

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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