I have this .htaccess file who does some redirecting and rewriting (removing extensions .. etc) but when i send data using the POST method it gets lost along the way.
tried adding this condition to stop Request with POST data from redirecting but it's not working.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^resume-.*/([0-9]+)$ /book.php?id=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^channel-books/([0-9]+)/([0-9]+)/([0-9]+)$ /getChannelBooks.php?idChaine=$1&page=$2&orderby=$3 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^channel-books/([0-9]+)/([a-zA-Z]+)$ /getChannelBooks.php?idChaine=$1&$2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^chaine-.*/([0-9]+)$ /model_contenu_de_chaine.php?idChaine=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^search-([0-9]+)$ /search_page.php?search=$1 [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^audio-([0-9]+)$ /audiobook.php?id=$1 [QSA]
RewriteRule ^$ /index.php [NC]
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} \s/([^.]+)\.php [NC]
RewriteRule ^ /%1 [NE,L,R=307]
RewriteRule ^([^\.]+)$ $1.php [NC]
Here's what my post request looks like
and this is the code in my destroy_session.php file
if(isset($_POST['action']) && $_POST['action'] == 'logout'){
session_unset("username");
session_destroy();
}
Here's what my post request looks like
That's the actual issue here, this not related to the URL rewriting.
PHP is not going to populate $_POST
, if you send a raw request like that. You need to send application/x-www-form-urlencoded
or multipart/form-data
.