L
L
legatobrown2020-02-08 02:46:11
PHP
legatobrown, 2020-02-08 02:46:11

How to remove redirects in .htaccess file that interfere with ajax?

Here is my ajax request:

$.ajax({
        url: '/' + url,
        type: 'POST',
        data: name + '_f=1' + str,
        cache: false,
        success: function (result) {
            alert(result);
        }
    });


here is what I have in .htaccess :

RewriteEngine on

RewriteRule /css/([^\/]+).css$ css/$1.css [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]


in the file register.php where ajax sends requests:

else if ($_POST['register_f']) {
        message('регистрация');
}


as a result, instead of the phrase 'registration', I get the html code from the page index.php

success result contains the page code, and not the response from php,

I specified that the problem is that all requests are written in .htacccess to redirect to one single page - the main one, that's it the question is how do i fix this? can add some exceptions, but how?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2020-02-08
@Stalker_RED

You now have a server configured with a single entry point - index.php. But it looks like you don't know how to use it.
It's not difficult to remove: just delete these lines with rewrite ***.
Although it would be cooler to learn how to work with it, because it has become almost a development standard many years ago.

F
FanatPHP, 2020-02-08
@FanatPHP

Your problem is not with the redirect, of course, but with the index.pohape file. Well, with logic, of course.
If your file starts to display htil for any request, then expecting that in response to an Ajax request it will display something else is at least naive.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question