CodeIgniter Forums
mod_rewrite - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: mod_rewrite (/showthread.php?tid=18645)



mod_rewrite - El Forum - 05-13-2009

[eluser]timaksu[/eluser]
so i developed my app and it works all good now. i gave it out to people to try and got alot of errors popping up all over the place. mod_rewire is the culprit, and users dont all have it enabled..which leads to 404's everywhere.

now i dont know what to do. offer an option without a clean url? how will that work with the clean url? ive already finished the app, i need to go back and redo all my links?

is there an alternative to mod_rewrite? :gulp:


mod_rewrite - El Forum - 05-13-2009

[eluser]Dam1an[/eluser]
Workaround:
Assuming you've done your links using the anchor function, you just need to checnge index_page in the config file to be 'index.php' and all your links will be back to normal

Solution:
If you know where mod_rewrite.c (or .so) is, you could maybe check if that file exists, and if so, have index_page to nothing, else having it to 'index.php'
This is of course assuming that its enabled if they have it, although I assume thats in your .htaccess file to include it


mod_rewrite - El Forum - 05-13-2009

[eluser]timaksu[/eluser]
awesome. i replaced the indexpage area in config.php with :

Code:
if(in_array('mod_rewrite',apache_get_modules())) {
$config['index_page'] = "";
}
else
{
$config['index_page'] = "index.php";
}

and the .htaccess is
Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ index.php [L]

RewriteCond $1 !^(index\.php|install\.php|style|js|robots\.txt|favicon\.ico)

RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

the php checks to see if we have mod_rewrite enabled, and if we do we use index.php/ and it works fine with the rest of the site.

i was using base_url() for my anchors (Adding page names to the end as needed, eg; echo base_url()."welcome/etc"Wink

would i have any problems with this? compatibility etc?


mod_rewrite - El Forum - 05-14-2009

[eluser]Dam1an[/eluser]
using base_url could be problamatic, see this thread

Basically, base_url doesn't return with URL with index.php even if its set as your index_page in config, but site_url does


mod_rewrite - El Forum - 06-01-2009

[eluser]Unknown[/eluser]
Hi, a newbie with a newbie question.
This is maybe a stupid question. Can't I remove /index.php/ from URL without mod_rewrite (my free webhost doesn't provide it)? I mean is there any internal CI codes that can do this?

Thanks.


mod_rewrite - El Forum - 06-02-2009

[eluser]TheFuzzy0ne[/eluser]
No, it can't be done without MOD_REWRITE.