mod_rewrite on GoDaddy

Permalink
I am trying to get pretty URL's running on GoDaddy. However I am running into an issue in which, when I go to:

http://mydomain.com/login

I get a C5 styled 404.

However when I go to:

http://mydomain.com/index.php/login...

I get the login page.

Since it's on GoDaddy, I don't think I can see the access and error logs to understand what is happening.

Has anyone run into, solved this?

jereme
 
jereme replied on at Permalink Reply
jereme
I've found that if I use a redirect rule, things work fine, but I don't get my pretty urls...I'm not sure what it's doing wrong.
andrew replied on at Permalink Reply
andrew
i tried really hard to get mod_rewrite and .htaccess working with GoDaddy and I wasn't able to do it. Whenever I started to put the code in there I kept getting "no input file specified" even though everything _had_ been working (I'd added php5.ini, applied the patch, setup cgi.fix_pathinfo.)

I know that Code Igniter and others have a patch where you use the query string and rewrite it to go to

index.php?$1 instead of

index.php/$1

but that won't work with C5...since we use stuff in our query string from time to time.
jereme replied on at Permalink Reply
jereme
If I output the request path from within dispatcher after the request object is loaded, I get a peek at what might be part of the issue.

/login pushed through mod_rewrite has a getRequestCollectionPath of '/index'

/index.php has a getRequestCollectionPath of '/login'

I'm going to keep investigating as to why.
jereme replied on at Permalink Reply
jereme
Around line 61 in request.php:

$path = str_replace($_SERVER['SCRIPT_NAME'], '', '/' . $path);


If $path == '/index.php/login', this converts it to '/index.php' instead of '/login'

Once that is done, the destination is lost and we're greeted with a loverly 404.
jereme replied on at Permalink Reply
jereme
Ah ha! $_SERVER['SCRIPT_NAME'] == '/login' when your code is expecting it to be '/index.php'

That is where the issue seems to really begin.
andrew replied on at Permalink Reply
andrew
I am going to try and build this into our next release candidate. Crossing fingers here...but it looks like the code in request.php should be able to catch more without being quite as prone to breaking.
chattojimnow replied on at Permalink Reply
chattojimnow
I have edited the request.php and the config file through my server all works until i go to edit a page and it goes to page not found.

Am i missing a step?
jereme replied on at Permalink Reply
jereme
I'm not sure if my patch will have ill effects, but it seems to work for my situation on GoDaddy, where, when using mod_rewrite, $_SERVER['SCRIPT_NAME'] == '/login', but $_SERVER['ORIG_SCRIPT_NAME'] == '/index.php'.

in request.php around line 61, I replace:

$path = str_replace($_SERVER['SCRIPT_NAME'], '', '/' . $path);


with

if($_SERVER['ORIG_SCRIPT_NAME']) {
  $path = str_replace($_SERVER['ORIG_SCRIPT_NAME'], '', '/' . $path);
} else {
  $path = str_replace($_SERVER['SCRIPT_NAME'], '', '/' . $path);
}
andrew replied on at Permalink Reply
andrew
Someone else mentioned ORIG_SCRIPT_NAME but i could never find it in phpinfo(). Must not have been outputting using mod_rewrite.
andrew replied on at Permalink Reply
andrew
Ok, actually i think I am lost.

What's the value of

$_SERVER['SCRIPT_NAME'];
$_SERVER['ORIG_SCRIPT_NAME'];

when it's index.php/login/ (with mod_rewrite off) as well as the value of the two when it's just '/login' (with mod_rewrite on?)
jereme replied on at Permalink Reply
jereme
mod_rewrite off:

/*
  When mod_rewrite is disabled, the SCRIPT_NAME is correct for the URL we are at, and ORIG_SCRIPT NAME is null;
$_SERVER['SCRIPT_NAME'] == '/index.php/login';
$_SERVER['ORIG_SCRIPT_NAME']) == null


mod_rewrite on:

$_SERVER['SCRIPT_NAME'] == '/login';
$_SERVER['ORIG_SCRIPT_NAME'] == '/index.php/login';
andrew replied on at Permalink Reply
andrew
did you find it took an inordinate amount of time for you r .htaccess file to be recognized?
jereme replied on at Permalink Reply
jereme
Funny thing... The first day it seemed like it took hours for any change to go through. After a few days it cooled off and changes would take place immediately.

I read somewhere that the trick is to put an empty .htaccess in place first and leave it there for awhile.

What in the hell is with that? Bastards!
brian30 replied on at Permalink Reply
brian30
To enable pretty URL's on godaddy go to your hosting manager then settings then file extensions. Change .php from PHP5x FastCGI to PHP5x
jereme replied on at Permalink Reply
jereme
There will be a pretty large performance penalty for this. If godaddy's servers are robust enough you may not notice it. However, FastCGI offers a great caching upside.

You did, however, propose a perfectly workable solution. Thanks :)
brian30 replied on at Permalink Reply
brian30
I did notice a slight lag after applying but not enough to make me change it back to fastcgi. I wouldn't recommend this for a site with alot of content. I would like to see someone attempt it that has a huge site to see how it effects their load time.