Ajax and admin requests stopped functioning by introducing mod-rewrite rules

I am new to rewriting URLs.

I wrote a few rewrite rules in the .htaccess file. My problem is that the ajax request and the admin section (both of which are managed by different files named ajax.php and admin.php) do not work at all.

Here is what I am trying to achieve with mod-rewrite:

URL: http://websitename/index.php?page=rr&cn=abc&cid=1
should look like this: http://websitename/rr/abc/1
in the address bar of the browser

and

URL (having only the value "page"): http://websitename/index.php?page=register
should look like this: http://websitename/register
in the address bar of the browser

and

URL: http://websitename/index.php?page=i&in=banking&iid=12
should look like this: http://websitename/industry/banking/12
in the address bar of the browser

and

URL: http://websitename/index.php?page=cr&cn=pqr&rid=12
should look like this: http://websitename/cr/pqr/12
in the address bar of the browser

, , , ajax.php admin.php , ( ).

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^([A-Za-z0-9-]+)/([^/]+)/([^/]+)$ index.php?page=$1&companyname=$2&companyid=$3%{QUERY_STRING} [L,QSA]

RewriteRule ^([^/]+)$ index.php?page=$1%{QUERY_STRING} [L,QSA]

RewriteRule ^view/([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&industryname=$2&industryid=$3%{QUERY_STRING} [L,QSA]

RewriteRule ^([^/]*)/([^/]*)/review/([^/]*)$ /index.php?page=$1&companyname=$2&reviewid=$3 [L]

mod-rewrite , ajax, "ajax.php", ( )

. URL- mod-rewrite
http://websitename/ajax.php?action=vote

http://websitename/admin.php?page=home

( ajax.php admin.php)

ajax.php admin.php

, . .

+3
3

, , URL, .

RewriteRule ^([^/]+)$ index.php?page=$1%{QUERY_STRING} [L,QSA]

URL-

htaccess , , , admin.php ajax.php ( , ):

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^/ajax.php(.*)$ /ajax.php$1 [L,QSA]
RewriteRule ^/admin.php(.*)$ /admin.php$1 [L,QSA]

RewriteRule ^([A-Za-z0-9-]+)/([^/]+)/([^/]+)$ index.php?page=$1&companyname=$2&companyid=$3%{QUERY_STRING} [L,QSA]

RewriteRule ^([^/]+)$ index.php?page=$1%{QUERY_STRING} [L,QSA]

RewriteRule ^view/([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&industryname=$2&industryid=$3%{QUERY_STRING} [L,QSA]

RewriteRule ^([^/]*)/([^/]*)/review/([^/]*)$ /index.php?page=$1&companyname=$2&reviewid=$3 [L]
+1

, , ajax.php admin.php 2 4 - '/'. mod_rewrite, - .

admin.php ajax.php, , .

0

RewriteRule :

RewriteCond %{REQUEST_FILENAME} !-s

With it, your rules will work only when they refer to a nonexistent file. Requests to exit files, in particular ajax.phpand admin.php, will be left verbatim.

-1
source

All Articles