Reputation: 4887
i need a %{HTTP_HOST}
environment variable without the port.
I have a dev server under 8080 port and prod server under 80.
This rule fail on dev because %{HTTP_HOST}
on dev server is eg.: myhost.com:8080
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}/%{REQUEST_URI}/index.html -f
RewriteRule ^(.*) "/cache/%{HTTP_HOST}/%{REQUEST_URI}/index.html" [L]
</IfModule>
there is a way for make HTTP_HOST without the port?
Upvotes: 0
Views: 1260
Reputation: 42925
Sure, you can simply parse the actual host from the combination of host and port:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ([^:]+)
RewriteCond %{DOCUMENT_ROOT}/cache/%1/%{REQUEST_URI}/index.html -f
RewriteRule ^(.*) "/cache/%{1}/%{REQUEST_URI}/index.html" [L]
Upvotes: 2