简体   繁体   中英

Form Post data not being sent after setting htacces rewrite rule

I am using the PHP-login.net framework for a login and I am hosting the folder in a subfolder of another website and using htaccess to redirect it to the main domain I created for that subfolder.

RewriteCond %{HTTP_HOST} ^(www.)?decathlon.ga$ [NC]
RewriteCond %{REQUEST_URI} !^/decathlon/.*$
RewriteRule ^(.*)$ /decathlon/$1 [L]

It worked fine when I had it just as saint57records.com/decathlon but when I added the redirect the POST data is not being sent from this form. However, all links are redirecting as they should.

<form action="http://decathlon.ga/login/login" method="post">
<label>Username (or email)</label>
<input type="text" name="user_name" required />
<label>Password</label>
<input type="password" name="user_password" required />
<input type="checkbox" name="user_rememberme" class="remember-me-checkbox" />
<label class="remember-me-label">Keep me logged in (for 2 weeks)</label>
<input type="submit" class="login-submit-button" />
</form>

On the page it goes to it performs this check and gives me the error that the POST is empty.

http://decathlon.ga/login/login portion below

if (!isset($_POST['user_name']) OR empty($_POST['user_name'])) {
    $_SESSION["feedback_negative"][] = FEEDBACK_USERNAME_FIELD_EMPTY;
    return false;
}

So everything is redirecting to the right place but does someone understand what might be going on with the POST data because of the redirect?

It's not 100% clear to me what you're trying to do, but you are redirecting everything not matching ^/decathlon/.*$ to /decathlon/$1 . That means that http://decathlon.ga/login/login redirects to http://decathlon.ga/decathlon/login/login , which seems wrong.

You need to rewrite your second RewriteCond and your RewriteRule , but it's impossible to guess what they should be without more information.

Your shown rule is not doing any external redirect , it is just an internal rewriting. Hence POST data will be preserved during this routing to /decathlon directory. I would suggest you to check presence of other rules doing this redirect. External redirect can also be caused by other module like mod_dir if login/login is a real directory.

As an alternative you can even avoid this rewrite by directly using /decathlon/ in the form's action path:

<form action="http://decathlon.ga/decathlon/login/login"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM