EllisLab text mark
Advanced Search
     
how to remove index.php from all of my methods or cntrollers and redirect them to without index.php url
Posted: 23 July 2012 10:38 AM   [ Ignore ]
Joined: 2012-07-12
37 posts

like when i have url like this

http://jobr.in/clients/the-school-shop/index.php/user/login

i want it to redirect to this one


http://jobr.in/clients/the-school-shop/user/login


i have done pretty research but none of them working

Thanks a lot

 
Posted: 23 July 2012 10:45 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2012-07-11
5 posts

In the documentation, it’s all noted…

http://ellislab.com/codeigniter/user-guide/general/urls.html 

The second header: Removing the index.php file

 
Posted: 23 July 2012 10:51 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-07-12
37 posts

have added this in my htacess file and its not making any diffrence

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

check this url

http://jobr.in/clients/the-school-shop/index.php/user/login

 
Posted: 23 July 2012 10:57 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2012-07-11
5 posts

Are you sure that mod_rewrite is enabled on your server?

Create a PHP page on your web server. For demonstration purposes, call this page phpinfo.php. This file should read as follows:

PHP Code:

<?php phpinfo(); ?> 

Now, navigate to this page in your browser and look under the Loaded Modules section. This can be located using Ctrl+F in your browser. In this list try and locate mod_rewrite. If it is listed here, you’re good to go. If not, you’ll need to enable it. (Source: http://www.codingforums.com/showthread.php?t=215977)

Also, make sure that you set

$config['index_page'''

in your application/config/config.php

 
Posted: 23 July 2012 11:47 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2012-07-12
37 posts

i have checked mod _rewrite has been enabled

also made this change
Also, make sure that you set
$config[‘index_page’] = ‘’; 

now its still same
http://jobr.in/clients/the-school-shop/index.php/user/login

 
Posted: 23 July 2012 11:59 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Joined: 2012-07-11
5 posts

I don’t see what is wrong with it now, go to http://jobr.in/clients/the-school-shop/user/login

it works, no?

 
Posted: 23 July 2012 12:31 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2012-07-12
37 posts

brother ,

you are not understanding the prob.


prob is both url are working already

http://jobr.in/clients/the-school-shop/index.php/user/login
http://jobr.in/clients/the-school-shop/user/login

but i have to redirect

http://jobr.in/clients/the-school-shop/index.php/user/login

to this
http://jobr.in/clients/the-school-shop/user/login


urls with index.php should not be accessible

 
Posted: 23 July 2012 12:45 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-19
3796 posts

It doesn’t matter if they are “accessible” if there aren’t any links to them (search engines only catalog actually links, and they don’t “guess”), unless these are old urls that you are trying to get out of search engines or something.

If you use the url helpers, like anchor(), then you won’t have to do anything else to clean up your urls once you change $config[‘index_page’] to empty string.  It won’t make links with “index.php” in them.  However, if you didn’t, and you manually created your anchors using straight up html, then you will have to fix all of those by hand and remove the “index.php”.  Hopefully you used the CI anchor() function.

The same goes for images and forms.  If you made them by hand instead of using CI’s helpers, you will have to manually fix all of them.

 Signature 
 
Posted: 23 July 2012 01:02 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Joined: 2012-07-11
5 posts

Yup, didn’t understand it.

Put this in your main controllers’ __construct after calling the parent::__construct()

if(preg_match('/index.php\/.*/',$_SERVER['REQUEST_URI'])){
     redirect
(current_url());
 

The $_SERVER[‘REQUEST_URI’] is a non-routed url, current_url() is already routed thru your routes.php config file.

Hope this helps.

 
Posted: 24 July 2012 01:12 AM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Joined: 2012-07-12
37 posts

CroNiX


i have used base_url()

to get urls and i have made $config[‘index_page’] = ‘’;  too

so now all links on my website are without index.php

but all links can be accessed if we add index.php

i just want to make sure this will not make any effect on seo of website

will not be these treated as duplicate content

thats all i want to know…..

 
Posted: 24 July 2012 01:18 AM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-19
3796 posts

No, it will not affect SEO.  Search engines can only follow links.  If you don’t make links with index.php in them, they won’t get cataloged.  If you make links that use both with and without index.php for the same link, then you will have a problem.

So it doesn’t matter if you can access them both ways.  Just only use one way to write the links, without the index.php.

 Signature 
 
Posted: 24 July 2012 01:27 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Joined: 2012-07-12
37 posts

Thanks a lot,


all links on my website are without index.php…...

 
Posted: 06 October 2012 08:14 AM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Joined: 2012-10-06
1 posts

Hi,

create file in your codeigniter folder name “.htaccess”

in that file add following code:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]

then save it. your problem will be solve.