我是 apache 的新手,我正在尝试使用 apache 将应用程序默认别名重写为更优雅的别名,但不幸的是,我很挣扎,找不到办法做到这一点
你能帮我吗 ?
我想要的是 :
- 服务器名称为(例如)server0123456.com
- 我的应用程序位于 server0123456.com:8080/myapp_backend
- 为服务器创建了一个 DNS 别名(cname?):mycompany.com
- mycompany.com/myapp_backend 运行良好(使用 RewriteRule ^(.*)$ /myapp_backend/ [R=302,L,NE]
- 但我希望 URL 是 mycompany.com/myapp,这样更优雅
- 如果对 mycompany.com 进行 ping,则必须重定向到 mycompany.com/myapp
这是我尝试过的
我的 vh 文件:
<VirtualHost *:80>
ServerName mycompany.com
DocumentRoot "/hawai/composants/apache/htdocs"
<Directory />
Order deny,allow
Allow from all
Options FollowSymLinks
AllowOverride All
</Directory>
EnableMCPMReceive
RewriteEngine On
RewriteCond %{REQUEST_METHOD} !^STATUS.*$
RewriteCond %{REQUEST_METHOD} !^INFO.*$
RewriteCond %{REQUEST_METHOD} !^CONFIG.*$
RewriteCond %{REQUEST_METHOD} !^ENABLE-APP$
RewriteCond %{REQUEST_METHOD} !^DISABLE-APP$
RewriteCond %{REQUEST_METHOD} !^STOP-APP$
RewriteCond %{REQUEST_METHOD} !^STOP-APP-RSP$
RewriteCond %{REQUEST_METHOD} !^REMOVE-APP$
RewriteCond %{REQUEST_METHOD} !^STATUS-RSP$
RewriteCond %{REQUEST_METHOD} !^INFO-RSP$
RewriteCond %{REQUEST_METHOD} !^DUMP$
RewriteCond %{REQUEST_METHOD} !^DUMP-RSP$
RewriteCond %{REQUEST_METHOD} !^PING$
RewriteCond %{REQUEST_METHOD} !^PING-RSP$
RewriteCond %{REQUEST_URI} !^/test.html.*$
RewriteCond %{REQUEST_URI} !^/cgi-bin.*$
RewriteCond %{REQUEST_URI} !^/mod_cluster_manager/.*$
RewriteCond %{REQUEST_URI} !^/server-status/.*$
RewriteCond %{REQUEST_URI} !^/maintenance.html$
RewriteCond %{REQUEST_URI} !^/static_myapp/.*$
RewriteCond %{REQUEST_URI} !^/myapp_backend/.*$
RewriteRule ^(.*)$ /myapp/ [R=302,L,NE]
</VirtualHost>
我的位置文件:
<Location "/myapp_backend/">
Options None
AllowOverride None
Order deny,allow
Allow from all
# mod_deflate
#AddOutputFilterByType DEFLATE text/html text/plain text/xml
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
DeflateFilterNote Ratio ratio
DeflateCompressionLevel 7
我需要添加 proxypass 吗?非常感谢您的帮助