CodeIgniter Forums
CodeIgniter URLs, .htaccess and all that stuff - 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: CodeIgniter URLs, .htaccess and all that stuff (/showthread.php?tid=13052)



CodeIgniter URLs, .htaccess and all that stuff - El Forum - 11-09-2008

[eluser]mradlmaier[/eluser]
Hello,

I am a newbie and obviously this question is asked many times, but I could not find a clear explanation how to exclude the index.php in the URls.
Could anybody please post a HOW-TO with all steps involved, which answers questions like
- Do I have to delete the code-igniter-root/index.php
- Where exactly goes the .htaccess? In code-igniter-root/system/application/controllers/ or in code-igniter-root/ ?
- What exactly does .htaccess contain?
- To which values do have what variables have to be changed in code-igniter-root/system/config/config.php
- Any other things to do?
That is for apache2.2 on openSUSE 11.
I tried many things to no avail, I only get 403, 404, 500 Errors.
Access with the index.php included in the URL works, though.

Big thanks in advance,
Michael


CodeIgniter URLs, .htaccess and all that stuff - El Forum - 11-09-2008

[eluser]bastones[/eluser]
The .htaccess file goes in the root folder (public_html/www/htdocs/ - whatever your root folder is), with the following:

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

...then go into system/application/config and open up the config.php file and change the following line:

Code:
$config['index_page'] = "index.php";

to:

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

(yes, blank)

Then everything should work for you. If you still cannot access without index.php, reply and I'll give you another solution that may work Smile.


CodeIgniter URLs, .htaccess and all that stuff - El Forum - 11-10-2008

[eluser]mradlmaier[/eluser]
Hello,

My exact configuration looks like this now

CodeIgniter is in /home/michi/ci with /home/michi/ci/.htaccess
/home/michi/ci is aliased as /ci/ in apache2, so I access this via http://127.0.0.1/ci/

I have the rewrite stuff exactly like you posted and the config file, too.

I get a 403 Error access is forbidden for http://127.0.0.1/ci/blog , http://127.0.0.1/ci/index.php and http://127.0.0.1/ci/index.php/blog

If I remove the .htaccess and change the config file back, everything works, but with the index,php included in the url.

:-S

Michael


CodeIgniter URLs, .htaccess and all that stuff - El Forum - 11-10-2008

[eluser]bastones[/eluser]
[quote author="mradlmaier" date="1226335637"]Hello,

My exact configuration looks like this now

CodeIgniter is in /home/michi/ci with /home/michi/ci/.htaccess
/home/michi/ci is aliased as /ci/ in apache2, so I access this via http://127.0.0.1/ci/

I have the rewrite stuff exactly like you posted and the config file, too.

I get a 403 Error access is forbidden for http://127.0.0.1/ci/blog , http://127.0.0.1/ci/index.php and http://127.0.0.1/ci/index.php/blog

If I remove the .htaccess and change the config file back, everything works, but with the index,php included in the url.

:-S

Michael[/quote]

You need the htaccess to be in root (www) directory, not inside the CI directory. And if its a local machine on Windows; that's bound to happen. It happened to me - I got forbidden errors 'till I removed .htaccess, etc.


CodeIgniter URLs, .htaccess and all that stuff - El Forum - 11-10-2008

[eluser]narkaT[/eluser]
try this Wink


CodeIgniter URLs, .htaccess and all that stuff - El Forum - 11-10-2008

[eluser]mradlmaier[/eluser]
Hello,

O.K. narkaT,

including the option FollowSymlinks in the directory section fixed it for me (As described in the wiki) . And the .htaccess is in /home/michi/ci which translates to URL 127.0.0.1/ci (alias in apache).

Thanks,
Michael