对于其中一个子路径,我尝试将访问限制为仅对来自 Intranet 的请求。我尝试了以下配置,但没有按预期工作。
<VirtualHost *:7777>
Debug ON
RewriteEngine On
RewriteOptions inherit
RewriteRule ^/$ /test1 [R,L]
RewriteRule ^/test2$ - [R=404] [L]
RewriteRule ^/stage$ /stage/test1 [R,L]
RewriteRule ^/stage/test2$ - [R=404] [L]
<IfModule weblogic_module>
WebLogicCluster localhost:7003,localhost:7005
</IfModule>
<Location /test1>
SetHandler weblogic-handler
</Location>
<Location /test2>
SetHandler weblogic-handler
</Location>
<Location /api>
SetHandler weblogic-handler
PathPrepend /test1
</Location>
<Directory /stage/test1>
Order deny,allow
deny from all
Allow from 192.168
Allow from 127
</Directory>
<Directory /stage/test2>
Order deny,allow
deny from all
Allow from 192.168
Allow from 127
</Directory>
<Directory /stage/api>
Order deny,allow
deny from all
Allow from 192.168
Allow from 127
</Directory>
<Location /stage/test1>
SetHandler weblogic-handler
WebLogicCluster localhost:7203,localhost:7205
PathTrim /stage
</Location>
<Location /stage/test2>
SetHandler weblogic-handler
WebLogicCluster localhost:7203,localhost:7205
PathTrim /stage
</Location>
<Location /stage/api>
SetHandler weblogic-handler
WebLogicCluster localhost:7203,localhost:7205
PathTrim /stage
PathPrepend /test1
</Location>
</VirtualHost>
有人可以帮我解决这个问题吗?
答案1
再次查阅 Apache 文档后,根据你的情况使用以下命令
<Location /stage/test1>
SetHandler weblogic-handler
WebLogicCluster localhost:7203,localhost:7205
PathTrim /stage
Order deny,allow
Deny from all
Allow from 192.168.1.3 127
</Location>
在位置部分应用访问限制。
答案2
这有效,但我不确定这是否是更清洁的方法。
RewriteCond %{REMOTE_ADDR} !^10
RewriteCond %{REQUEST_URI} !^stage/(.*)
RewriteRule ^/stage/(.*) - [R=404] [L]