Amjad
Amjad

Reputation: 2100

form submit stops working after adding .htaccess file

I've added the following .htaccess file

RewriteEngine On
RewriteBase /site/public/admin/

RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+) [NC]
RewriteRule ^ %1/caseid/%2/? [R=302,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/caseid/([^/]+)/?$ $1.php?caseid=$2 [L,NC,QSA]

## hide .php extension snippet    
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=302,L]

# add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

after adding the above code my form submit button is stopped working. HTML form tag is below

<form role="form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" id="rta_parties_form">

    <?php require_once 'php_include/parties/form_parties.php';?>

</form>

I've tried the following as well but that also not working.

RewriteCond %{REQUEST_METHOD} !POST

Not good in Mode Rewrite stuff

Any Idea?

Upvotes: 2

Views: 818

Answers (2)

Sharif
Sharif

Reputation: 728

You can try the following in your .htaccess file

RewriteCond %{REQUEST_METHOD} !POST [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

you can use the that link for compelete answer

Upvotes: 1

anubhava
anubhava

Reputation: 786349

Insert this rule after RewriteBase line to skip rewrite rules for POST requests:

RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]

Upvotes: 2

Related Questions