I have this .htaccess file that does some redirects and rewrites (removing extensions, etc.), but when I send the data using the POST method, it gets lost along the way.
Tried adding this condition to prevent request redirection using POST data, but it doesn't work.
Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^resume-.*/([0-9]+)$ /book.php?id= [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=&page=&orderby= [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=& [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^chaine-.*/([0-9]+)$ /model_contenu_de_chaine.php?idChaine= [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^search-([0-9]+)$ /search_page.php?search= [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^audio-([0-9]+)$ /audiobook.php?id= [QSA] RewriteRule ^$ /index.php [NC] RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{THE_REQUEST} \s/([^.]+)\.php [NC] RewriteRule ^ /%1 [NE,L,R=307] RewriteRule ^([^\.]+)$ .php [NC]
This is what my post request looks like
This is the code in my destroy_session.php file
if(isset($_POST['action']) && $_POST['action'] == 'logout'){ session_unset("username"); session_destroy(); }
P粉3333954962024-01-11 11:18:01
That's the actual issue here, it has nothing to do with URL rewriting.
If you send a raw request like this, PHP will not populate $_POST
. You need to send application/x-www-form-urlencoded
or multipart/form-data
.