BACKGROUND :
I have a Rails app where my home page is products/index.
I'm using the following code in my .htaccess file to redirect requests from products/ to root.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*products\ HTTP/
RewriteRule ^(.*)products /$1 [R=301,L]
This is working great. Requests to /products are redirecting to root, and requests to products/[id] are still routing to products/id as I would want.
PROBLEM :
The only problem is that I have an admin section with the namespace /admin. And in that admin section, I have /products.
So now when my admin user is in the admin section of the site and he clicks on the "products" link, he should be routed to url/admin/products. However, the rewrite rule is redirecting him to url/admin
QUESTION
How do I exclude the admin prefix from the redirect code I listed above?
I imagine that somewhere in the regex I should be able to add something like: [^admin] But I can't get anything to work.
Thanks.
Add another rewrite condition like this to start off:
RewriteCond %{REQUEST_URI} !^admin
This will disable the following rewrite rules for any request starting with admin.
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.