Reputation: 1008
I want to change all request uri in my project if the request contains phrase "ajax". For example now I have:
http://www.address.com/ajax/getIdeas
And when the user changes language it adds /ru/
in the URL. So the link became http://www.address.com/ru/ajax/getIdeas
and its not working. All I want to do, is to change via .htaccess all links which contains word ajax
and ru
. So if the request is http://www.address.com/ru/ajax/getIdeas
it should redirect to http://www.address.com/ajax/getIdeas
. How to do it?
Upvotes: 0
Views: 44
Reputation: 20745
I would recommend against making rules to rewrite, or redirect, your ajax requests. Redirects will cause your POST ajax requests to stop working. Your rewrites in general will cause extra, unnecessary work to occur regardless.
In your case I would recommend fixing your scripts to not use language-specific ajax-requests where they do not cause different results. You would use an url relative to your root (/ajax/page
) instead of relative to your current url (ajax/page
).
Upvotes: 1
Reputation: 786091
You can use this rule in your DOCUMENT_ROOT/.htaccess
file to remove 2 digit language rom start of your URLs:
RewriteEngine On
RewriteRule ^[a-z]{2}/(ajax/.*) /$1 [L,NC,R=301]
Upvotes: 1