0
私は、HTTPヘッダーHTTP_CF_IPCOUNTRYの国コードをサーバーに提供するのにcloudflareを使用しています。httpヘッダーから国コードを取得し、それをApacheのurlパラメーターに追加します。
httpヘッダーから国コードを取得し、.confファイル(仮想ホスト)を使用してapacheサーバーのurlパラメータに追加する必要があります。それは可能ですか?
Serverバージョン:Apacheの/ 2.4.7(Ubuntuの)
私は、角distのフォルダを持っていると私は、Apacheサーバを使用してファイルを提供することだし、URLパラメータで国を必要としています。
PHPサービスと角度アプリの両方のための私の設定ファイル(/コンサルテーション/ *)
<VirtualHost *:80>
ServerName hero.azure
ServerAlias hero.com
ErrorLog /var/log/apache2/error.log
DocumentRoot /var/www/hero/public
SetEnv APPLICATION_ENV "testing"
AliasMatch ^/consultation(.*) "/var/www/ng2/dist/index.html"
Alias "/ng2" "/var/www/ng2/dist/ng2/"
<Directory /var/www/hero/public>
<LimitExcept OPTIONS>
AuthType Basic
AuthName "user"
AuthUserFile /etc/apache2/htpass
Require user user
</LimitExcept>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
、ここでは、クエリにこのルールを追加することで解決
RewriteEngine on
RewriteCond %{QUERY_STRING} country
RewriteRule ^/consultation(.*)$ ^/consultation/(.*)?country="%{CF-IPCOUNTRY}i"&%{QUERY_STRING} [QSA]
try URLリライトコンセプトhttps://stackoverflow.com/questions/12133079/adding-the-original-url-as-header-or-que ry-parameter-re-rewriterule https://httpd.apache.org/docs/2.0/misc/rewriteguide.html私はjavaを使用しています。これは非常に有用な式http://tuckey.org/urlrewrite/manual/3.0を使用しています/guide.html – shareef