{"id":8643,"date":"2017-06-28T12:30:45","date_gmt":"2017-06-28T03:30:45","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=8643"},"modified":"2017-06-28T13:26:35","modified_gmt":"2017-06-28T04:26:35","slug":"location%e3%83%98%e3%83%83%e3%83%80%e3%81%ae%e6%83%85%e5%a0%b1%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8bvba%e3%83%9e%e3%82%af%e3%83%ad","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=8643","title":{"rendered":"Location\u30d8\u30c3\u30c0\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308bVBA\u30de\u30af\u30ed"},"content":{"rendered":"<p>\u901a\u5e38\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u308bWeb\u30da\u30fc\u30b8\u3092\u958b\u3044\u305f\u3068\u304d\u3001<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php\r\nheader('Location: https:\/\/www.ka-net.org\/blog\/');\r\nexit;<\/pre>\n<p>HTTP\u30d8\u30c3\u30c0\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">GET \/redirect.php HTTP\/1.1\r\nHost: localhost\r\nUser-Agent: Mozilla\/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko\/20100101 Firefox\/54.0\r\nAccept: text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8\r\nAccept-Language: ja,en-US;q=0.7,en;q=0.3\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\n\r\nHTTP\/1.1 302 Found\r\nDate: Wed, 28 Jun 2017 02:39:48 GMT\r\nServer: Apache\/2.4.10 (Win32) OpenSSL\/1.0.1i PHP\/5.5.15\r\nX-Powered-By: PHP\/5.5.15\r\nLocation: https:\/\/www.ka-net.org\/blog\/\r\nContent-Length: 3\r\nKeep-Alive: timeout=5, max=100\r\nConnection: Keep-Alive\r\nContent-Type: text\/html<\/pre>\n<p>\u3053\u308c\u3092\u898b\u308b\u3068\u3001Location\u30d8\u30c3\u30c0\u3067\u79fb\u52d5\u5148\u306e\u30da\u30fc\u30b8\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u5206\u304b\u308a\u307e\u3059\u3002<br \/>\n\u3053\u306e\u5024\u3092VBA\u304b\u3089\u53d6\u5f97\u3059\u308b\u5834\u5408\u3001WinHttpRequest\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u666e\u901a\u306b\u51e6\u7406\u3059\u308b\u3068\u3001<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Private Sub Sample1()\r\n  With CreateObject(&quot;WinHttp.WinHttpRequest.5.1&quot;)\r\n    .Open &quot;HEAD&quot;, &quot;http:\/\/localhost\/redirect.php&quot;, False\r\n    .Send\r\n    Debug.Print &quot;Status:&quot; &amp; .Status\r\n    Debug.Print &quot;----------&quot;\r\n    Debug.Print &quot;Headers:&quot;\r\n    Debug.Print &quot;----------&quot;\r\n    Debug.Print .GetAllResponseHeaders\r\n  End With\r\nEnd Sub<\/pre>\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306b<span style=\"color: #ff0000; font-weight: bold;\">\u201c\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u5148\u306e\u60c5\u5831\u201d<\/span>\u304c\u53d6\u5f97\u3055\u308c\u3066\u3057\u307e\u3044\u3001Location\u30d8\u30c3\u30c0\u306e\u5185\u5bb9\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">Status:200\r\n----------\r\nHeaders:\r\n----------\r\nConnection: Keep-Alive\r\nDate: Wed, 28 Jun 2017 02:45:24 GMT\r\nKeep-Alive: timeout=2, max=100\r\nContent-Type: text\/html; charset=UTF-8\r\nServer: Apache\r\nX-Powered-By: PHP\/5.3.3\r\nLink: &lt;https:\/\/www.ka-net.org\/blog\/?rest_route=\/&gt;; rel=&quot;https:\/\/api.w.org\/&quot;, &lt;https:\/\/wp.me\/4UZZr&gt;; rel=shortlink<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306a\u5834\u5408\u306b\u306f\u3001Option\u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u30ea\u30c0\u30a4\u30ec\u30af\u30c8(<a href=\"https:\/\/msdn.microsoft.com\/ja-jp\/library\/aa384108.aspx\" title=\"WinHttpRequestOption enumeration (Windows)\" target=\"_blank\">WinHttpRequestOption_EnableRedirects<\/a>)\u3092\u7121\u52b9\u306b\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u3001Location\u30d8\u30c3\u30c0\u306e\u60c5\u5831\u304c\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Private Sub Sample2()\r\n  MsgBox GetRedirectUrl(&quot;http:\/\/localhost\/redirect.php&quot;), vbInformation + vbSystemModal\r\nEnd Sub\r\n\r\nPublic Function GetRedirectUrl(ByVal url As String) As String\r\n  Dim ret As String\r\n  Const WinHttpRequestOption_EnableRedirects = 6 'WinHttp.WinHttpRequestOption\r\n  \r\n  On Error Resume Next\r\n  With CreateObject(&quot;WinHttp.WinHttpRequest.5.1&quot;)\r\n    .Open &quot;HEAD&quot;, url, False\r\n    .Option(WinHttpRequestOption_EnableRedirects) = False '\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u7121\u52b9\r\n    .Send\r\n    Select Case .Status\r\n      Case 302: ret = .GetResponseHeader(&quot;Location&quot;)\r\n    End Select\r\n  End With\r\n  On Error GoTo 0\r\n  GetRedirectUrl = ret\r\nEnd Function<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GetRedirectUrl_01.jpg\" alt=\"\" width=\"294\" height=\"191\" class=\"alignnone size-full wp-image-8644\" \/><\/p>\n<p>\u30de\u30af\u30ed\u3067Location\u30d8\u30c3\u30c0\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u6a5f\u4f1a\u3082\u305d\u3046\u591a\u304f\u306f\u7121\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u3069\u306a\u305f\u304b\u306e\u53c2\u8003\u306b\u306a\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<\/p>\n<div id=\"single_banner_area2\" class=\"clearfix one_banner\">\n<div class=\"single_banner single_banner_left\">\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- \u8a18\u4e8b\u4e2d(\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u5e83\u544a\u30e6\u30cb\u30c3\u30c8) -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-7306936664602087\"\r\n     data-ad-slot=\"5429724765\"\r\n     data-ad-format=\"auto\"\r\n     data-full-width-responsive=\"true\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\n<\/div>\n<div class=\"single_banner single_banner_right\">\n<a href=\"\" target=\"_blank\"><img decoding=\"async\" src=\"\" alt=\"\" title=\"\" \/><\/a>\n<\/div>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"\u901a\u5e38\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u308bWeb\u30da\u30fc\u30b8\u3092\u958b\u3044\u305f\u3068\u304d\u3001 &lt;?php header(&#8216;Location: https:\/\/www.ka-net.org\/blog\/&#8217;); exit; HTTP\u30d8\u30c3\u30c0\u306f\u4e0b\u8a18\u306e\u3088\u3046 [&hellip;]","protected":false},"author":1,"featured_media":7120,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"[Location\u30d8\u30c3\u30c0\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308bVBA\u30de\u30af\u30ed]","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,48,49,58],"tags":[],"class_list":["post-8643","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-office","category-word-office","category-powerpoint"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-OfficeVBA.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-2fp","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8643"}],"version-history":[{"count":2,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8643\/revisions"}],"predecessor-version":[{"id":8646,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8643\/revisions\/8646"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7120"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}