Welcome Guest, Not a member yet? Register   Sign In
CI + mod_rewrite + CI = ?
#1

[eluser]Lovecannon[/eluser]
okay, I use the standard rewrite for removing the index.php from urls, as indicated by the documentation. I use Lunar Pages for my host, and they support PHP 4 & 5, and the redirects work fine in PHP4, but when I use PHP5, the only url that works is my default one(the welcome page url), but when I try to use any other URL, it doesnt work, and only loads the default URL..anyone know why?


This is my .htaccess for index.php rewriting:

RewriteCond $1 !^(index\.php|template\.html|test\.html|jsmart|css|hazrdshock|catsup|adobe|bah|env|images|cgi-bin|user_guide|forums|stylesheets|javascript|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
#2

[eluser]daniel.affonso[/eluser]
Here in the forum have a lots of htaccess solutions, the one that was usefull to me:

Code:
RewriteEngine on

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

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

This is means all requests that not a existent folder or file will be redirect to the index.php

I hope this is help you...
#3

[eluser]Lovecannon[/eluser]
No, that didnt help at all. It still refuses to load any modules other than Welcome
#4

[eluser]chrisco23[/eluser]
Did you ever resolve this? I'm stuck on this problem now.
#5

[eluser]daniel.affonso[/eluser]
If your directory schema is simple, try to use RewriteBase:

Code:
RewriteEngine on

RewriteBase /root_app_directory/

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]
#6

[eluser]chrisco23[/eluser]
Thanks, but unfortunately my directory is not too simple. Maybe that is part of my problem. Right now I have the following:

/dev <!-- this will eventually be the main docroot but I'm replacing a live site so this is temporary
/CodeIgniter_1.7.0
/private/main_application
/private/admin_application

Anybody see any issues with doing this re: Lunarpages?

btw, I never saw those 2 lines you have with SCRIPT_FILENAME in them. Did you find that to become necessary on some servers?
#7

[eluser]daniel.affonso[/eluser]
About RewriteBase, its must be setted to the directory of the application, not to the main root.

If I remove SCRIPT_FILENAME on my apps they break.

In all my apps I use successfully the htaccess above and the exceptions are in
config/routes.php

Maybe Lunarpages requires specific configuration... do you try the support?

Good luck
#8

[eluser]chrisco23[/eluser]
Lunarpages support has been helpful but understandably there is a limit to what they can support when it comes to third party (code igniter) and apache htaccess rules.

Are you on shared hosting? For you, is RewriteBase an absolute path?
#9

[eluser]daniel.affonso[/eluser]
Yes, I'm on shared.

Im'not using a absolute path with RewriteBase.

One example about RewriteBase:

On windows box the path to my htdocs folder is:
c:\dev\htdocs\

For one hypothetical App (called my_app) the path is:
c:\dev\htdocs\my_app\

The rewritebase line at htaccess:
RewriteBase /my_app/

Simple just this Big Grin (but i believe you have already tried this)
#10

[eluser]chrisco23[/eluser]
sikkle gave me the answers I needed.

I had two problems really.

One was that to get things working with suPHP (what lunarpages uses), I had to add one line to the top of index.php:
Code:
$_SERVER['PATH_INFO'] = str_replace('?'.$_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI']);
then I had to use "PATH_INFO" as the uri protocol (in config.php).

Now, that info will probably be useful to other people but I also had another more obscure issue. I was using a controller action (method name) called "view". Again it was sikkle who pointed out to me that that naming can't be used on PHP 4, which is what my friend's lunarpages hosting currently is.

So, I can finish my fix just by renaming to "views" or whatnot. However I already had a ticket in progress to migrate to a server running PHP 5 / MySQL 5, so in theory everything will just work anyway if I wait for that. This is a rebuild of a live site anyway and will require some QA so it's not really urgent that I do this renaming right this second.

Thanks for your replies, was really a tough one.


Chris




Theme © iAndrew 2016 - Forum software by © MyBB