Heart Internet subfolder mod rewrite issues
Permalink
BACKGROUND:
I'm sure I'm not the first person to have similar issues to this:http://www.concrete5.org/community/forums/chat/hosting-with-heart-i...
But, I've been trying to install Concrete5 in a subfolder on a Heart Internet hosted account i.e.:www.www.example.com/extn/index.php...
Note: Installing C5 is usually no problem for me. I've done it several times on other hosts without problems. As before these are the basic steps I've done:
1. Edit libraries/request.php line 77 to if ($path === false) {
$path = "";
}
2. Modified site.php: define('DIR_REL', '');
3. Setup htaccess to rewrite all page requests:
-http://www.example.com/login ->www.www.example.com/extn/index.php/login...
... and all file requests go to:
-http://www.example.com/main.css ->www.www.example.com/extn/main.css...
This htaccess works for my other sites. Testing it to rewrite normal html files on Heart works perfectly (i.e. if I drop the index.php from mod rewrite). Only problem is when it comes to finding files through the "index.php"!
PROBLEM:
http://www.example.com/login should go to->www.www.example.com/extn/index.php/login...
However all that comes up is "No input file specified."
Only when you go towww.www.example.com/extn/index.php/login...
will the page appear.
- All resources on the page are linked without the "/extn" subfolder reference and load with no problems
Clearly mod_rewrite hasn't done anything to find index.php!
Note: A phpinfo()+tests show cgi.fix_pathinfo=1
A POSSIBLE (BUT UNDESIRABLE) SOLUTION:
Redirect through the a php file on the root folder:
http://www.concrete5.org/community/forums/installation/no_input_fil...
This only seems to work since mod_rewrite is glitchy. It's certainly not an ideal solution since I'm worried about future mod_rewrites I might have issues with.
Short of moving everything to the root folder does anyone have a solution? - I've attached a pdf of my phpinfo()
I still have time to change host based on Heart Internet's guarentee if it doesn't work out!
Cheers!
I'm sure I'm not the first person to have similar issues to this:http://www.concrete5.org/community/forums/chat/hosting-with-heart-i...
But, I've been trying to install Concrete5 in a subfolder on a Heart Internet hosted account i.e.:www.www.example.com/extn/index.php...
Note: Installing C5 is usually no problem for me. I've done it several times on other hosts without problems. As before these are the basic steps I've done:
1. Edit libraries/request.php line 77 to if ($path === false) {
$path = "";
}
2. Modified site.php: define('DIR_REL', '');
3. Setup htaccess to rewrite all page requests:
-http://www.example.com/login ->www.www.example.com/extn/index.php/login...
... and all file requests go to:
-http://www.example.com/main.css ->www.www.example.com/extn/main.css...
This htaccess works for my other sites. Testing it to rewrite normal html files on Heart works perfectly (i.e. if I drop the index.php from mod rewrite). Only problem is when it comes to finding files through the "index.php"!
PROBLEM:
http://www.example.com/login should go to->www.www.example.com/extn/index.php/login...
However all that comes up is "No input file specified."
Only when you go towww.www.example.com/extn/index.php/login...
will the page appear.
- All resources on the page are linked without the "/extn" subfolder reference and load with no problems
Clearly mod_rewrite hasn't done anything to find index.php!
Note: A phpinfo()+tests show cgi.fix_pathinfo=1
A POSSIBLE (BUT UNDESIRABLE) SOLUTION:
Redirect through the a php file on the root folder:
http://www.concrete5.org/community/forums/installation/no_input_fil...
This only seems to work since mod_rewrite is glitchy. It's certainly not an ideal solution since I'm worried about future mod_rewrites I might have issues with.
Short of moving everything to the root folder does anyone have a solution? - I've attached a pdf of my phpinfo()
I still have time to change host based on Heart Internet's guarentee if it doesn't work out!
Cheers!
UPDATE:
So after several discussions with Heart's support team wasting time I couldn't find a fix - (basicly identifying the "script filename" which their php has issues identifying)
BOTTOMLINE: I settled for a hack - I'm still with Heart for now.
SIMPLE TEST:
I proved this was an issue with their server with a very simple test:
Create a file to carry out
And use a very simple .htaccess rewrite to prove it:
Rewriterule (.*) phpinfo.php/$1
I.e. Rewrites all URLs:
http://www.example.com/fish ->www.www.example.com/phpinfo.php/fish...
This test worked perfectly (as expected) loading phpinfo() on another server - however on Heart it didn't load for some reason. - Painful!
SOLUTION:
Basicly you can set up a htaccess file to send pathinfo as a variable in the URL so you can use $_GET['pathinfo'] to retrieve it.
Then you need to go about redefining all the $_SERVER variables which "SHOULD" have been automatically identified correctly - but weren't..
To install in a subfolder I used a redirect.php file on the root (technically optional) to "require()" index.php.
Not an ideal hack but works without any side-effects so far as I can see at the moment.
NOTE:
The core of the issue here is that Heart's servers just aren't finding the correct SCRIPT_FILENAME when you rewrite a URL serverside!
Add a [R=302] flag to your htaccess and it works.. (obviously that defeats the point of rewriterule) grrrr....
If anyone's got any better solution - perhaps involving setting variables through php5.ini? (I've tried a lot with no success.. Heart's support didn't really have a clue..) - I'm sure others and myself would love to hear it!
Cheers
So after several discussions with Heart's support team wasting time I couldn't find a fix - (basicly identifying the "script filename" which their php has issues identifying)
BOTTOMLINE: I settled for a hack - I'm still with Heart for now.
SIMPLE TEST:
I proved this was an issue with their server with a very simple test:
Create a file to carry out
<?php phpinfo();?>
And use a very simple .htaccess rewrite to prove it:
Rewriterule (.*) phpinfo.php/$1
I.e. Rewrites all URLs:
http://www.example.com/fish ->www.www.example.com/phpinfo.php/fish...
This test worked perfectly (as expected) loading phpinfo() on another server - however on Heart it didn't load for some reason. - Painful!
SOLUTION:
Basicly you can set up a htaccess file to send pathinfo as a variable in the URL so you can use $_GET['pathinfo'] to retrieve it.
Then you need to go about redefining all the $_SERVER variables which "SHOULD" have been automatically identified correctly - but weren't..
To install in a subfolder I used a redirect.php file on the root (technically optional) to "require()" index.php.
Not an ideal hack but works without any side-effects so far as I can see at the moment.
NOTE:
The core of the issue here is that Heart's servers just aren't finding the correct SCRIPT_FILENAME when you rewrite a URL serverside!
Add a [R=302] flag to your htaccess and it works.. (obviously that defeats the point of rewriterule) grrrr....
If anyone's got any better solution - perhaps involving setting variables through php5.ini? (I've tried a lot with no success.. Heart's support didn't really have a clue..) - I'm sure others and myself would love to hear it!
Cheers
Just a heads up, all of my sites using the Heart Internet mod rewrite hack stopped working with pretty URLs last night!
After a lengthy discussion with the support team Heart say they haven't changed anything, which I seriously doubt.
Anyway, have gone back to the original .htaccess contents as shown in the c5 dashboard and it is fully working now!
I just wish they would have told us...
After a lengthy discussion with the support team Heart say they haven't changed anything, which I seriously doubt.
Anyway, have gone back to the original .htaccess contents as shown in the c5 dashboard and it is fully working now!
I just wish they would have told us...
Thanks for that. I've just found one of my clients sites was broken. Reverting to the standard code rather than the hack appears to have fixed it. (Also hosted on Heart).
In the ends I got them to admit that they had made changes, and they promised that they were going to fix it again so that both methods work. To be honest I find the previous heart hack no longer works reliably, so I changed everything to the standard c5 code and all is good.
this seems to be broken again but oddly for only one site of many on the same vh....
ok the fix for me was
in php.ini add
cgi.fix_pathinfo = 1;
and from heart:
This line must be added to your config/site.php file:
define('SERVER_PATH_VARIABLE', 'REDIRECT_URL');
And these lines need adding to your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L] --#notice this line has been changed! and remove this comment --
</IfModule>
in php.ini add
cgi.fix_pathinfo = 1;
and from heart:
This line must be added to your config/site.php file:
define('SERVER_PATH_VARIABLE', 'REDIRECT_URL');
And these lines need adding to your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L] --#notice this line has been changed! and remove this comment --
</IfModule>
http://www.concrete5.org/community/forums/installation/no-input-fil...
I've tried this on my server and it appears to load most things. However Cid's don't appear to get parsed and dashboard/sitemap/full returns a 500 error.
Anyone got any cleaner solutions? - something to parse path_info in request.php better?
Marc also posted code that apparently works for fastCGI users. No sucess on my side:
http://www.concrete5.org/developers/bugs/5-4-1-1/path_info-problem/...