Welcome Guest, Not a member yet? Register   Sign In
Eliminating the index.php
#1

[eluser]GabrieleMartino[/eluser]
Hello,

i have changed

$config['index_page'] = '';

I have tried with several .htaccess and i could not understand if is necessary to write them this way

Code:
<IfModule !mod_rewrite.c>
#<IfModule !mod_rewrite.so>
  ErrorDocument 404 index.php
</IfModule>

or this way

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

as in the guide. Anyway they doesn't work both.

Neither if i change the

$config['uri_protocol'] = ... in the 5 possible values
#2

[eluser]CroNiX[/eluser]
Try:
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Which tells apache to pass everything that isn't an actual file (like a css asset) and isn't an actual directory (like an asset directory), to CI's bootstrapper index.php. If that doesn't work, try removing the ? after index.php in the rewrite rule.
#3

[eluser]GabrieleMartino[/eluser]
I mean when i call an method should i put the index.php/controller/method or not like conroller/method.

Because before it works the second but i have to create a htaccess for being read by the host.
#4

[eluser]CroNiX[/eluser]
It should make it work without index.php in the url. So you should be able to go to http://yoursite.com/controller/method, but yes, you need the htaccess in order to do that. The purpose of that htaccess is so that you don't HAVE to have index.php appear in the url, but it will still work if it is there.

If you are using site_url() helper to generate your links, then it will automatically add index.php (or not) depending on the $config['index_page'] setting. If it is set to 'index.php', then it will add index.php to the urls. If it is blank, it won't use index.php in the url and you then need the htaccess to make it work.
#5

[eluser]GabrieleMartino[/eluser]
The system do not work with the .htaccess. I reported with firebug:

404 Not Found

for controller/method

Other element in the page are not properly load.

NetworkError: 404 Not Found - http://localhost/safememoirs/pages/get_secondary"

which is called inside javascript with

Code:
$.ajax({
            type: "POST",
            dataType: "json",
            url:base_url+ "pages/get_secondary",
            data: postData ,
            success: function(secondaries){ ...
#6

[eluser]CroNiX[/eluser]
Are you sure that you have mod_rewrite enabled as an apache module?

It also looks like you have your CI installed in a subdirectory (safememoirs), instead of document_root, so additional work will probably need to be done. Its much simpler setting up a virtual host in apache for each project.

You could try adding
RewriteBase /safememoirs/
to your htaccess (just after RewriteEngine On) to fix that, but you'd have to change it again on your live site, which is why it's really best to set up a virtual host so your development site will mimic the live site as far as the structure.
#7

[eluser]GabrieleMartino[/eluser]
I had the module switched off by defualt in the apache config on opensuse.

Anyway it seems not read the .htaccess file.

What is the exact name of the file .htaccess ? Or there is a prefix to give?

Is it possible to have another .htaccess that is not possible to overwrite with the one in localfolder?
#8

[eluser]Rowan Wilson[/eluser]
Try this one:

Code:
RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

The filename is how you've already written it: .htaccess and it must live in the root of your CI installation at the same level as application and system.

FYI the dot in the filename makes it a hidden file if you are looking for it in the terminal.
#9

[eluser]GabrieleMartino[/eluser]
This is not working, but i have a doubt

Do I have to remove the file index.php from root, deleting it I mean?

Because if so can be It doesnt' start for IDE configuration and not for .htaccess!

If so I'm sorry, but It as not been unuseful the help.
#10

[eluser]Rowan Wilson[/eluser]
No don't delete index.php. That's the main CI script. Just put a file called .htaccess in the root of your CI folder.




Theme © iAndrew 2016 - Forum software by © MyBB