CodeIgniter Forums
Error Removing index.php from url (Need Help URGENT Please) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Error Removing index.php from url (Need Help URGENT Please) (/showthread.php?tid=31790)

Pages: 1 2


Error Removing index.php from url (Need Help URGENT Please) - El Forum - 07-01-2010

[eluser]GK[/eluser]
Hi all,

i am trying to remove index.php from url(hostelsearch.in),

1.i've added htaccess file

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

2. I've also changed my baseurl to hostelsearch.in in config.php & $config['uri_protocol'] = "AUTO";

3. My Default controller is HostelSearch (changed in routes.php)

4. Rewrite mode is activated too


Now, the problem is when i call hostelsearch.in its showing "404 Page not FOUND".

but if i call any function of the controller(HostelSearch) then its working.

hostelsearch.in/index
hostelsearch.in/about

Any suggestions ? what i am missing ? or anything else required ? please reply asap ...


Error Removing index.php from url (Need Help URGENT Please) - El Forum - 07-01-2010

[eluser]proximityfuse[/eluser]
Make sure the server has rewrite module activated. I learned this yesterday hehe Smile
Try $config['uri_protocol'] = "REQUEST_URI";


Error Removing index.php from url (Need Help URGENT Please) - El Forum - 07-01-2010

[eluser]GK[/eluser]
thanks for the reply. I tried but not working Sad


Error Removing index.php from url (Need Help URGENT Please) - El Forum - 07-01-2010

[eluser]mdhb2[/eluser]
try this .htaccess

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

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>
it work like a charm for me


Error Removing index.php from url (Need Help URGENT Please) - El Forum - 07-01-2010

[eluser]danmontgomery[/eluser]
When you have the controller in your htaccess, if the default controller is called the system will be looking for:

index.php/HostelSearch/HostelSearch

which doesn't exist. This happens to work when you call other methods because codeigniter thinks it's given the controller name, but you've provided the controller name in htaccess and are giving it the method name:

index.php/index becomes index.php/HostelSearch/index

You will have significantly less headache if you use the routing functionality the way it was designed, and keep your CI logic out of htaccess.


Error Removing index.php from url (Need Help URGENT Please) - El Forum - 07-01-2010

[eluser]GK[/eluser]
Thanks Nick, tried but stil not working Sad


Error Removing index.php from url (Need Help URGENT Please) - El Forum - 07-01-2010

[eluser]pickupman[/eluser]
Make sure you have defined your default_controller in /config/routes.php It appears CI doesn't know where to look because there are no segments to match your .htaccess rule, and will load index.php. index.php will try loading the defined controller.


Error Removing index.php from url (Need Help URGENT Please) - El Forum - 07-01-2010

[eluser]GK[/eluser]
Noctrum, i've also tried without Default controller by using

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


but this time it is showing (404) other methods.


Error Removing index.php from url (Need Help URGENT Please) - El Forum - 07-01-2010

[eluser]pickupman[/eluser]
Now your .htaccess is correct. In application/config/routes.php you should have this:
Code:
$route['default_controller'] = 'HostelSearch';



Error Removing index.php from url (Need Help URGENT Please) - El Forum - 07-01-2010

[eluser]GK[/eluser]
yes this is already done $route['default_controller'] = "HostelSearch";