I'm trying to achieve this kind of mod_rewrite:
*if request_uri is not abc or def* change client side url from
domain.com/request_uri
to server side url
domain.com/xyz/request_uri
Essentially what I want is to insert a string to a url without users knowledge if s/he isn't trying to access certain predefined urls.
So far I have
RewriteCond %{REQUEST_URI} ^/abc$
RewriteRule ^(\w+)/?$ xyz/$1 [L]
but this seems to get stuck in a loop (/xyz//xyz//xyz...)
Add a condition to check for the component you're adding. You can use an additional RewriteCond
or extend the regex. Try something like:
RewriteCond %{REQUEST_URI} !^/?(xyz(/.*)|abc|def)/?$
RewriteRule ^(\w+)/?$ xyz/$1 [L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.