I'm a new comer to url-spinning.

I've written couple of rewrite rules within the .htaccess file. My problem would be that the ajax request and also the admin section (each of which are now being handled by different files, named ajax.php and admin.php) no longer working whatsoever.

Here's what I'm attempting to achieve using mod-rewrite :

The URL : http://websitename/index.php?page=rr&cn=abc&cid=1
need to look such as this : http://websitename/rr/abc/1
within the addressbar of browser

and

The URL (getting only 'page' value): http://websitename/index.php?page=register
need to look such as this : http://websitename/register
within the addressbar of browser

and

The URL : http://websitename/index.php?page=i&in=banking&iid=12
need to look such as this : http://websitename/industry/banking/12
within the addressbar of browser

and

The URL : http://websitename/index.php?page=cr&cn=pqr&rid=12
need to look such as this : http://websitename/cr/pqr/12
within the addressbar of browser

To date I can do that while using following rules however the request designed to ajax.php and admin.php together with some parameters aren't working whatsoever (page not found error).

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]

All of the three mod-rewrite rules work fine however the ajax demands that's carried out by another file named "ajax.php" aren't working (page not found error comes)

i.e. the next Web addresses should use above mod-rewrite rules
http://websitename/ajax.php?action=vote
and
http://websitename/admin.php?page=home

(don't wish to have mod-rewrite rules for that files ajax.php and admin.php)

But I'm not in a position to effectively get it done for ajax.php and admin.php

Help me about this. I'm really stuck about this.

Thanks

In the looks from it, it seems in my experience your next rewrite rule could be catching each of the URL's you won't want to have rewritten.

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

These two URL's could be acquired within the above rewrite rule

I would recommend altering your htaccess towards the following, all it's attempting to do is catch the admin.php, or ajax.php calls and send them straight through unchanged (I've not checked this but it ought to be ok):

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]

An offhand guess, maybe the ajax.php and admin.php get merged into rules 2 or 4 due to the key '/'. I am a bit hazy around the exact workings of mod_rewrite, however it may have something related to it.

Try add rule by rule and try out the admin.php and ajax.php pages to determine which rules are earning individuals pages fail.

Prefix every RewriteRule using the following:

RewriteCond %{REQUEST_FILENAME} !-s

By using it your rules works only if they reference an inexistent file. Demands for exiting files particularly ajax.php and admin.php is going to be left verbatim.