Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
[Solved] 404 Page Not Found Errors - AJAX Only
j2234
✭
I'm suddenly getting 404 Not Found errors for certain AJAX requests. An example screenshot from the registration page is attached.
It is saying that it's getting a 404 for this URL, but when I load it in the browser, it shows TRUE:
/forum/dashboard/user/usernameavailable/asdf
I read this tutorial and my .htaccess file seems to be fine. I've posted a copy of it here.
I'm also getting errors for similar AJAX requests like: "The requested URL /profile/notificationspopin was not found on this server." The URL does exist when loaded in the browser.
Version number: 2.1
PHP Version 5.3.28
If you want to reproduce the bug, you can fill out the registration form and the errors will show before you submit the form.
Thanks in advance...
Tagged:
0
Comments
Here's a little more info:
The error messages look like this:
The requested URL /dashboard/user/emailavailable was not found on this server.
But in the browser console, the requested URL is:
codeselfstudy.com/dashboard/user/emailavailable?email=asdf
It should be codeselfstudy.com/forum/dashboard/user/emailavailable?email=asdf.
How do I tell the forum to include the "forum/" in the URL? It isn't that the page doesn't exist -- the forum is requesting the wrong URL.
Edit: I've also deleted all the .ini files in the cache folders.
I think I found the bug.
applications/dashboard/js/entry.js?v=2.1
The code says:
var checkUrl = gdn.url('/dashboard/user/emailavailable');
which won't work on forums that are in subdirectories, because it's requesting dashboard with a leading slash.
I'll double-check it and then submit a bug report, if that's what the problem is.
your checkUrl is evaluating to
/dashboard/user/emailavailable
if its not rewriting urls it should be prefixing with
/forum/index.php?p=
it should look like this. checkUrl should evaluate to
/forum/index.php?p=/dashboard/user/emailavailable
you might try in conf/config.php so your urls are rewritten.
then checkUrl should evaluate to:
/forum/dashboard/user/emailavailable
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Thanks for the reply. I have RewriteUrls set to TRUE. Here's that section of the config file:
$Configuration['Garden']['InputFormatter'] = 'Html';
$Configuration['Garden']['Version'] = '2.1';
$Configuration['Garden']['RewriteUrls'] = TRUE;
$Configuration['Garden']['Cdns']['Disable'] = FALSE;
$Configuration['Garden']['CanProcessImages'] = TRUE;
$Configuration['Garden']['SystemUserID'] = '2';
$Configuration['Garden']['Installed'] = TRUE;
The rewriting of URLs works, but it appears to be requesting the wrong URL in the JavaScript.
The JavaScript says:
var checkUrl = gdn.url('/dashboard/user/emailavailable');
but there is no Vanilla installation at / -- just at /forum. I'll check what the gdn.url method does in the meantime.
but its not rewriting otherwise you wouldn't see this
http://codeselfstudy.com/forum/entry/register?Target=discussions
is your .htaccess being read? and is it located in the /forum folder.
and is modrewrite working.
you could also try
$Configuration['Garden']['RewriteUrls'] = FALSE;
and see if that works.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
In order to use mod_rewrite you can type the following command in the terminal:
a2enmod rewrite
restart apache.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
check your php loaded modules
for
mod_rewrite
you can use php_info
or you can download the
http://vanillaforums.org/addon/versioncheck-plugin
which has it included for easy viewing from the dashboard.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
as you can see rewritng is not taking place when you click register other wise it wouldn't be going to the url in the first image.
and your checkUrl is not prefixing the /forum/index.php?p=
as it should if rewriting is not taking place. (perhaps because you don't have modrewrite enabled, yet you specify in config that you will be rewriting).
the leading / , that you are chasing is a red herring I believe.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I'm a bit confused. I think the rewriting is working, because URLs like this work:
http://codeselfstudy.com/forum/discussion/6/welcome-to-the-site
If rewrites weren't working, wouldn't there would be an index.php?p=/path/to/the/page in the URL?
I think it still uses query strings for redirects even when rewriting is on. Even on this vanillaforums.org site, registration URLs have query strings for the redirect:
/entry/register?Target=discussion%2Fcomment%2F212500
Unfortunately, it's a managed server, but I'm sure that .htaccess works for rewriting in general, since I have a lot of sites on the server. This is from their FAQs:
http://qa.site5.com/advanced/does-site5-have-mod_rewrite-enabled/
It does work now for the moment, because I just hardcoded /forum in the JavaScript file. But I'm not sure if that will cause problems down the road.
you can obviously verify with phpinfo to see if module is loaded.
you could be correct. it just seems odd.
I think something is wrong with UrlFormat in your setup for whatever reason.
var urlFormat = gdn.definition("UrlFormat", "/{Path}");
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
phpinfo() isn't showing mod_rewrite or anything that begins with mod_, but I think it's enabled -- otherwise the rewriting wouldn't work on the discussion URLs. I've sent a support ticket just to be sure though.
You don't think it's a problem with the client side? The JavaScript is omitting the "forum" directory from the URL on AJAX requests. So it requests this:
codeselfstudy.com/dashboard/user/emailavailable?email=fdsa
rather than this:
codeselfstudy.com/forum/dashboard/user/emailavailable?email=fdsa
Is there something in the PHP that would tell the gdn.url() method to use "forum"? I'm still looking through the JS...
Thanks for your help, by the way.
I haven't heard back from the hosting company yet, but this .htaccess rewrite rule works, for example:
http://codeselfstudy.com/forums/structure-and-interpretation-computer-programs-first-meeting-24.html
(watch the redirect from that to a Vanilla-style URL)
If I delete the .htaccess file and turn off rewriting in the config file, I get URLs like this and the 404 AJAX errors still appear:
codeselfstudy.com/forum/index.php?p=/entry/register&Target=discussion%2F6%2Fwelcome-to-the-site
Does anyone know if there are settings in the database that might affect this, or could I just re-upload all the Vanilla files and hope it overwrites whatever might have gone wrong?
just for grins can you post your entire config.php
but leave out sensitive info like passwords, salts, keys and email stuff.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Sure, I'll post it in a minute.
The hosting company said that mod_rewrite is enabled, but that it won't show in phpinfo(). This is their reply:
you might want to console log value of the variable urlFormat
here
https://github.com/vanilla/vanilla/blob/2.1/js/global.js#L637
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Here's the config file:
https://gist.github.com/j127/c4006913dd3e2b897764
Good idea. I just tried that and it isn't creating the correct URL.
Screenshot of the console:
nothing pops out at me.
you might want to console log value of the variable urlFormat
here is what I changed to adding console.logging.
https://github.com/vanilla/vanilla/blob/2.1/js/global.js#L637
then look at your console log
e.g. mine shows when I try to register testuser. my folder is /vanilla
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
your urlFormat seems to evaluate to
/{Path}
the differences could be I'm testing on local host. but logging should give you some ideas.
not sure but possibly config statement with webroot might help. not sure.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.