.htaccess 实现域名免端口访问服务
.htaccess Implement domain name without port access service
您想使用。 htaccess文件实现路径
中有'API'时访问指定端口的服务
类型与nginx相同:
location /api/ {
proxy_pass http://localhost:8385;
}
在 .htaccess
中,您需要使用 mod_rewrite 才能通过 mod_proxy 发送请求。以下是发布的 Nginx 配置的等价物:
RewriteEngine On
RewriteRule ^api/ http://localhost:8385%{REQUEST_URI} [P]
但是,您可能需要访问服务器配置以确保 mod_proxy(以及相关模块已安装)。
而且,如果您有权访问服务器配置,那么最好先在主服务器配置中执行此操作。例如:
ProxyPass /api/ http://localhost:8385/api/
ProxyPassReverse /api/ http://localhost:8385/api/
您想使用。 htaccess文件实现路径
中有'API'时访问指定端口的服务类型与nginx相同:
location /api/ {
proxy_pass http://localhost:8385;
}
在 .htaccess
中,您需要使用 mod_rewrite 才能通过 mod_proxy 发送请求。以下是发布的 Nginx 配置的等价物:
RewriteEngine On
RewriteRule ^api/ http://localhost:8385%{REQUEST_URI} [P]
但是,您可能需要访问服务器配置以确保 mod_proxy(以及相关模块已安装)。
而且,如果您有权访问服务器配置,那么最好先在主服务器配置中执行此操作。例如:
ProxyPass /api/ http://localhost:8385/api/
ProxyPassReverse /api/ http://localhost:8385/api/