apache .htaccess重新值捕获所有管理员请求



试图使我的.htaccess条件工作,但它们似乎无法正常工作,特别是我要删除/admin/directory的第二组 - 它一直在开始陷入第一组条件

# If the request is either /admin/ or /admin/index.html, rewrite to just admin.html
# http://foo.com/admin/
# http://foo.com/admin/index.html
RewriteCond %{REQUEST_URI} ^/admin/$ [OR]
RewriteCond %{REQUEST_URI} ^/admin/index.html$
RewriteRule ^ admin.html [L]
# if the request starts w/ /admin/, then remove the /admin folder and continue processing
# http://foo.com/admin/bar/baz.css
RewriteCond %{REQUEST_URI} ^/admin/.*$
RewriteRule ^/admin/(.*)$ /$1
# if any resource is not a directory or file, then rewrite to the index.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [L]

这是一个映射,它应该如何工作

group one

  • http://foo.com/admin-> http://foo.com/admin.html
  • http://foo.com/admin/index.html-> http://foo.com/admin.html

group two

  • http://foo.com/admin/bar/baz.css-> http://foo.com/bar/baz.css
  • http://foo.com/admin/baz.css-> http://foo.com/baz.css

group three

  • http://foo.com/bar/baz.css-> http://foo.com/bar/baz.css(假设/bar/baz.css存在)
  • http://foo.com/bar/baz.css-> http://foo.com/index.html(假设/bar/baz.css不存在)

为什么不消除第一组规则,然后让第二组处理所有管理员重定向。然后在apache set admin.html中to默认文档?

最新更新