404 Page not found using form submission

In localhost all is okay.

But I have a hosting where in the /public_html/site folder I have the main WordPress site. I have another PHP site which has no htaccess in /public_html/site/BETA.

You can login here: http://yoursocialtool.com/BETA/login.php User: stack Password: overflow Now the problem is when I am trying to logout after login using a form submission to the same page like as http://yoursocialtool.com/BETA/dashboard.php it says:

404 Page not found!

But if I directly put the url in the browser address bar http://yoursocialtool.com/BETA/dashboard.php then its loading fine without any 404 error.

The .htaccess in /public_html:

RewriteOptions inherit

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursocialtool.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yoursocialtool.com$
RewriteCond %{REQUEST_URI} !site/
RewriteRule (.*) /site/$1 [L]

The .htaccess in /public_html/site:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]
</IfModule>

# END WordPress

Here is the codes which I am using in my dashboard.php:

<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
ini_set('error_log','error.log');
require("config.inc.php");
require("__require_login.php");
require_once("_isconnected.php");
if (isAppLoggedIn()){
    require("_dashboard.html.php");
} else {
    echo ($msg);
    ?>
    <script>
window.location = "./login.php?from=dashboard&location=";
window.location.assign("./login.php?from=dashboard&location=assign");
    </script>
    <?php
}
?>

And the problem which I am facing is that the code is not executing JavaScript redirect in the server after login. Actually its not getting the dashboard.php after I am submitting the logout request although it seems to have logout successfully. I am handling the logout action in the dashboard.php also. Seems to be that the /public_html/site/index.php is handling it only after the logout submission.

NB: My localhost have only the part of the site under /public_html/site/BETA. So the localhost does not have any htaccess or wordpress.


In localhost all is okay.

Only because it works on localhost it must not need to work everywhere. This is why it is inherently important that your development version of the server-configuration is close (if not identical) to the server-configuration you deploy it to later on.

For that use virtualization and try to reproduce the 404 on your localhost then.

Getting the same behavior on both ends is a first sane check to do in troubleshooting the issue. From the current information you provide in your question this is the best suggestion I can give.

The short answer is: The configuration between both systems differ. Take care you are able to use the same configuration on both systems which includes not only configuration directives but also the same version of all softwares involved, for example the same version of the webserver, the same operating system and the same version of PHP (albeit PHP does not seem to be the issue here).


I moved the site to a subdomain. After that I see 500 error with 404. I have found out the solution consulting with the Apache system administrator. They had showed me that there was error in the log like below:

malformed header from script. Bad header=

Then I found that the server is not supporting the redirection in server side php script. Then I disable the redirection in server and now its working fine. I used JavaScript redirect.

<?php
//header('Location: http://www.example.com/');//Use JavaScript to redirect instead. Comment it out
exit;
?>

If someone must need the redirection then may try using the construct exit; just after the header declaration. Otherwise use JavaScript.

链接地址: http://www.djcxy.com/p/48348.html

上一篇: TYPO3重定向到另一个域的根页面

下一篇: 使用表单提交未找到404页面