Welcome Guest, Not a member yet? Register   Sign In
htaccess
#1

[eluser]Bl4cKWid0w[/eluser]
I can't get my htaccess file to work correctly. I want to remove index.php from the url's, but the htaccess code from the guide messes everything up. How do I do this?
#2

[eluser]Stefano G[/eluser]
Hi, there are many useful posts about this topic but... :p

in the
Code:
application/configconfig.php
file make sure that the index page is set to blank


Code:
$config['index_page'] = "";


this is as important as the .htaccess file.


Then you could use this file as your .htaccess file:


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


Last but not least, are you sure that mod_rewrite is available on your provider's apache server? and are you sure that in YOUR localhost apache server is mod_rewrite enabled?

If you installed XAMPP or similar make sure that everything's ok on that side as well!

There is a method for checking that mod_rewrite is enabled: googling for "test if mod_rewrite enabled" I happened to open this page.

Cheers!

Stefano
#3

[eluser]Bursh[/eluser]
I fixed this issue by placing the .htaccess file in the base folder; the same one as index.php appears in and just using the basic rewrite code provided by the user guide.
#4

[eluser]Xeoncross[/eluser]
Super .htaccess
#5

[eluser]Stefano G[/eluser]
[quote author="Bursh" date="1219371604"]I fixed this issue by placing the .htaccess file in the base folder; the same one as index.php appears in and just using the basic rewrite code provided by the user guide.[/quote]

...oops this is something I forgot to mention but I assumed it was obvious Wink
#6

[eluser]coldautumn[/eluser]
I was looking around for same topic, and found your discussion .I got same problem but the solution didnt make any difference. It gives following error message

Quote:500 Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

I have removed index from other site, which is not based code igniter, and it worked okay. Proves that, mod_rewriting is enabled. I have placed the file on same level where index.php resides.

Need suggestions. Thank you
#7

[eluser]Stefano G[/eluser]
The Internal Server error is probably due either to a wrong configuration file (did you modify your httpd.conf recently?) or an error in your .htaccess file.

The config file I have enclosed is suitable when you have codeigniter index.php file and .htaccess at the ROOT level of your server.

if you have several projects on your htdocs folder

Code:
htdocs <--- root level
  +
  |
  +---- projectone
  |
  +---- another project
  |
  +---- mycodeigniterproject
              +
              |
              +-- system
              +-- .htaccess
              +-- index.php

then you should modify your .htacess as follows:

Code:
RewriteRule ^(.*)$ /mycodeigniterproject/index.php?/$1 [L]

or

Code:
RewriteBase /mycodeigniterproject
...
RewriteRule ^(.*)$ index.php?/$1 [L]             <--- WITHOUT leading slash!!!

also remember to modify the
Code:
application/config/config.php

as follows:

Code:
$config['base_url']= "http://localhost/mycodeigniterproject/";  <--- WITH a trailing slash!!!
$config['index_page'] = "";

Hope it helps!

Stefano
#8

[eluser]coldautumn[/eluser]
Thanks for the guidance. Nope, that didnt resolve it. But removed the error message. Now shows Error 404 "Page not found".

There is something missing in url, as its

this => "http://localhost/Linked//welcome/skill" instead of being
this => "http://localhost/Linked/welcome/skill"
#9

[eluser]Stefano G[/eluser]
Have a look at your
Code:
application/config/routes.php
how does the default_cotroller looks like?

mine is :

Code:
$route['default_controller'] = "start"; <--- WITHOUT slashes!!!


so either if I type http://localhost/citestapp/start or http://localhost/citestapp/ I am redirected to the index method of my Start.php controller
#10

[eluser]coldautumn[/eluser]
no problem with default controller as defined

$route['default_controller'] = "welcome";

The .htaccess file include this

RewriteRule ^(.*)$/Linked/index.php?/$1 [L]

Havent add RewriteEngine on, as when I include the statment, html error 500 occurs, as mentioned before.

Is there a way , I can confirm that apache is accepting htaccess directives and some good resource, where I could learn htaccess coding.


Thanks for the guidance.




Theme © iAndrew 2016 - Forum software by © MyBB