Error Removing index.php from url (Need Help URGENT Please)

#1
[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 ...

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

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

#4
[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

#5
[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.

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

#7
[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.

#8
[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.

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

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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