开发者

301 Redirect, but exclude namespace

开发者 https://www.devze.com 2023-01-24 16:49 出处:网络
开发者_JS百科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.

开发者_JS百科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.

0

精彩评论

暂无评论...
验证码 换一张
取 消