• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to remove index.php from all of my methods or cntrollers and redirect them to without index.php url

#1
[eluser]dhananjay[/eluser]
like when i have url like this

http://jobr.in/clients/the-school-shop/i...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

#2
[eluser]nfdevil[/eluser]
In the documentation, it's all noted...

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

The second header: Removing the index.php file

#3
[eluser]dhananjay[/eluser]
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/i...user/login

#4
[eluser]nfdevil[/eluser]
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:
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
Code:
$config['index_page'] = '';
in your application/config/config.php

#5
[eluser]dhananjay[/eluser]
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/i...user/login

#6
[eluser]nfdevil[/eluser]
I don't see what is wrong with it now, go to http://jobr.in/clients/the-school-shop/user/login

it works, no?

#7
[eluser]dhananjay[/eluser]
brother ,

you are not understanding the prob.


prob is both url are working already

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

but i have to redirect

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

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


urls with index.php should not be accessible


#8
[eluser]CroNiX[/eluser]
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.

#9
[eluser]nfdevil[/eluser]
Yup, didn't understand it.

Put this in your main controllers' __construct after calling the parent::__construct()
Code:
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.

#10
[eluser]dhananjay[/eluser]
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.....


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.