Redirects are failing - help!

Login or register to post comments
10 replies [Last post]
LaCeja's picture
Offline
Joined: 11/04/2009

Hi folks. I've been banging my head against the wall on this one for hours and cannot figure it out.

I'm deploying a new QCubed application, which was developed on an xampp system and was working perfectly. Now, I'm moving it to a linux (cPanel managed) server and I cannot get the redirects to work. The obvious thing is that mod_rewrite isn't installed. However, I've verified it is installed and on. I have the following in my .htaccess file:

Options +FollowSymlinks
RewriteEngine on

And, I'm getting no errors. I've checked the log files and find nothing to indicate it's not working. Also, ran httpd -l | grep mod_rewrite and it responds with mod_rewrite.c. So, I know mod_rewrite is compiled into Apache.

However, the result from the redirect looks something like this:

document.location="/support/htwlive/wla/arcashrcptsbatches_list.php"

In my configuration.inc.php, I have:

define ('__DOCROOT__', '/home/myhtw/public_html');
define ('__VIRTUAL_DIRECTORY__', '');
define ('__SUBDIRECTORY__', '/support/htwlive');
define ('__FORM_MYFORMS__', __SUBDIRECTORY__ . '/wla');

The redirect looks like this:

QApplication::Redirect(__VIRTUAL_DIRECTORY__ . __FORM_MYFORMS__ . '/arcashrcptsbatches_list.php');

Obviously, I'm missing something, but I don't know what. I really need some help... Please!

Thanks,

Merrill

Offline
Joined: 08/06/2010

Try ful path
document.location.href='http://www...

or
window.location.href=

LaCeja's picture
Offline
Joined: 11/04/2009

Thanks for the reply, Mile. I still haven't figured out a solution, but the reason is that all Ajax calls are failing. All Ajax actions are failing. For example, if I change the action on the button to be QServerAction, instead of QAjaxAction, it works.

Is there some configuration setting I need to make for this to work?

kon
Offline
Joined: 12/08/2009

what does it redirect to?
also you can enable mod_rewrite logs, see here:
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog

and make sure to set the RewriteLogLevel too to something useful, you might have to try out some different values so you don't get too much information but also not too little. 2 or 3 should be fine. If you have problems making sense of the logs you can paste them on pastebin and then put a link here.

Maybe you need to set http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritebase too

LaCeja's picture
Offline
Joined: 11/04/2009

kon, thanks for the reply.

That's the problem, even though mod_rewrite is installed and on, it doesn't seem to be redirecting. For example, when I call QApplication::CloseWindow;, I get the error:

An error occurred during AJAX Response parsing.

When I click "OK", I get a popup, which has in it: window.close(); It's like mod_rewrite isn't working.

I'm totally lost!

Offline
Joined: 08/12/2009

1) I'd check with your host provider if mod_security is installed and is blocking ajax requests based on some strict rules.

Can you perform ajax requests with no problems without qcubed?

2) maybe some custom javascript is returning an error (I've had problems with double / single quotes escaping properly)

LaCeja's picture
Offline
Joined: 11/04/2009

I'm checking into mod_security now. Unfortunately, I have no other applications installed. It's a brand new server, but I've tried examples and they also fail.

kon
Offline
Joined: 12/08/2009

If you have full control over this apache installation i highly recommend you enable logging and see the logs (error logs as well as mod_rewrite logs). i am quite sure the answer lies in there. If you can't modify the logging settings by yourself you can ask your hoster nicely to enabled them and make them available to you.
you want the raw apache error log and the mod_rewrite log, however don't forget to disable the mod_rewrite log after you fixed the problem, as depending on your rule sets it can grow very quickly.

LaCeja's picture
Offline
Joined: 11/04/2009

Thanks again kon. I do have the apache and suphp log files and they are indeed very interesting. However, this morning, I tried something else to get a little more informaiton. I was testing a script that makes a redirect to another script, passing it a parameter. Here's the redirect:

QApplication::Redirect(__VIRTUAL_DIRECTORY__ . __FORM_MYFORMS__ . '/Vendors_edit.php/' . $strParameter);

This results in a 404, page not found, like this:

The requested URL /htwlive/wla/Vendors_edit.php/1166 was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Does this mean I need to create a mod_rewrite rule to convert the directory path to a URL? I've been doing all the development on an xampp system, so I imagine it all worked, because it was a Windows system. Now, I'm trying to put this on a cPanel managed CentOS machine and I really don't know what I'm doing.

How do I correct this problem?

kon
Offline
Joined: 12/08/2009

hey LaCeja

look here and try something like this:
http://qcu.be/content/htaccess-redirection-using-modrewrite

LaCeja's picture
Offline
Joined: 11/04/2009

Thanks kon. Yes, I had read that, but discounted it, because I followed the lead of the drafts and use pathinfo(0)... quite a bit.

Anyway, I have it working now. I decided to just move it all to a folder under the web root and turn off mod_rewrite for now. After I get everything working the way I want, I'll study up on how to write the conditions and rules for mod_rewrite and get it secured.

One interesting note, however, QApplication::CloseWindow doesn't work, even with mod_rewrite turned of and using Ajax. I had to replace it with a javascript to close windows. I don't understand why it doesn't work, but it was much quicker to just replace it with a QApplication::ExecuteJavaScript("window.close()");. I imagine 2.0.2 uses javascript.

Thank you very much for all your help!

Merrill