4

I developed one web application in which I used codeigniter, Structure of all the URLs of my web application is as follows:

<?php echo base_url();?>/Admin/Promotions

this type of links are working well in my Localhost but not working on my hosting server (I'm using Godaddy hosting)

But some links which have index.php in URLs are working both on localhost and server too structure of this king of links are

<?php echo base_url();?>index.php/Admin/Pramotions

What shoud I do so that URLs without index.php works well ??

My HTACCESS :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>
6
  • what about your .htaccess? Commented Jan 1, 2017 at 6:17
  • index.php is removed by .htaccess fle. Check your .htaccess file Commented Jan 1, 2017 at 6:18
  • But how to work with links with no index.php e.g.(<?php echo base_url();?>/Admin/Promotions) Commented Jan 1, 2017 at 6:20
  • Add RewriteBase /your-Folder-Name/ after RewriteEngine On Commented Jan 1, 2017 at 6:22
  • Codeigniter automatically adds in the base url, you do not need to do this "<?php echo base_url();?>/Admin/Promotions" Just use the last part, "Admin/Promotions" Commented Jan 2, 2017 at 14:41

4 Answers 4

4

Use this htaccess --

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

then set base_url --

$config['base_url']='http://www.domain_name.com';

then remove index.php in config file --

$config['index_page'] = '';

after that it will work without index.php

Sign up to request clarification or add additional context in comments.

Comments

1

Open config.php and do following replaces

$config['index_page'] = "index.php"

to

$config['index_page'] = ""

Just replace

$config['uri_protocol'] ="AUTO"

to

$config['uri_protocol'] = "REQUEST_URI"

AND IN HTACCESS FILE put following code

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

1 Comment

@Abhijit Kumbhar : answer provided
1

If none of the answers above worked, perhaps you need to activate mod_rewrite in your httpd.conf:

On terminal:

sudo nano /etc/httpd/conf/httpd.conf

ctrl + w to find for "rewrite"

Uncomment this line:

LoadModule rewrite_module modules/mod_rewrite.so

Save and restart httpd (apache).

Comments

0

It is working for me ....htaccess file is like this...

    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

And don't forget to set

$config['base_url']='http://www.domain_name.com';

2 Comments

Is this htaccess code working for links with no index.php incuded ??
And using htaccess code given by you , Im getting error "No input file specified."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.