{"id":5449,"date":"2024-05-01T12:55:41","date_gmt":"2024-05-01T03:55:41","guid":{"rendered":"https:\/\/taitan916.info\/blog\/?p=5449"},"modified":"2024-03-13T22:08:19","modified_gmt":"2024-03-13T13:08:19","slug":"post-5449","status":"publish","type":"post","link":"https:\/\/taitan916.info\/blog\/archives\/5449","title":{"rendered":"CodeIgniter4\u3067\u7279\u5b9a\u306e\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u304c\u3042\u3063\u305f\u969b\u306b301\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u305b\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>CodeIgniter4\u3067\u7279\u5b9a\u306e\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u304c\u3042\u3063\u305f\u969b\u306b301\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u305b\u305f\u3044\u3002\u8abf\u3079\u305f\u3068\u3053\u308d.htaccess\u30d5\u30a1\u30a4\u30eb\u3067\u306e\u5bfe\u5fdc\u3067\u306f\u306a\u304f\u3001redirect()\u95a2\u6570\u306b\u5f15\u6570\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u5bfe\u5fdc\u3067\u304d\u308b\u6a21\u69d8\u3002\u4ee5\u4e0b\u306b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u53ca\u3073\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306e\u30e1\u30e2\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>Redirect()\u95a2\u6570<\/h2>\n<h3>\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/h3>\n<p><a href=\"https:\/\/codeigniter4.github.io\/userguide\/outgoing\/response.html#redirect-status-code\" target=\"_blank\" rel=\"noopener\">https:\/\/codeigniter4.github.io\/userguide\/outgoing\/response.html#redirect-status-code<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<h3><span id=\"appConfigRoutesphp\">\/app\/Config\/Routes.php<\/span><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#301\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u30c6\u30b9\u30c8\r\n$routes-&gt;add('\/redirect_test', 'Test_Controller::index');<\/pre>\n<h3><span id=\"appControllersContactphp\">\/app\/Controllers\/Test_Controller.php<\/span><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?php\r\nnamespace App\\Controllers;\r\n\r\nclass Test_Controller extends BaseController\r\n{\r\n    public function index()\r\n    {\r\n        return redirect()-&gt;to('\/', 301);\r\n    }\r\n}<\/pre>\n<p>\u300chttps:\/\/test.com\/codeigniter4\/redirect_test\u300d\u3092\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u958b\u304f\u3068\u300chttps:\/\/test.com\/codeigniter4\/\u300d\u306b301\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u308b\u306e\u304c\u78ba\u8a8d\u3067\u304d\u308b\u7b48\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u305d\u306e\u4ed6<\/h2>\n<h3>\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3057\u306a\u3044\u5834\u5408<\/h3>\n<p>\u4e0a\u8a18\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3060\u3068\u300credirect()-&gt;to('\/', 301);\u300d\u3068\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u3092301\u306b\u6307\u5b9a\u3057\u3066\u3044\u308b\u304c\u3001\u6307\u5b9a\u3057\u306a\u3044\u5834\u5408\u306f302\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u305f\u3002\u307e\u305f\u3001\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306b\u4ee5\u4e0b\u6848\u5185\u304c\u3042\u308b\u3002<\/p>\n<blockquote><p>GET\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306eHTTP\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u306f 302 \u3067\u3059\u3002\u305f\u3060\u3057\u3001HTTP\/1.1 \u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u3001\u4ee5\u964d\u3067\u306f\u3001POST\/PUT\/DELETE \u30ea\u30af\u30a8\u30b9\u30c8\u306b\u306f303\u304c\u4f7f\u7528\u3055\u308c\u3001\u305d\u306e\u4ed6\u3059\u3079\u3066\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u306f 307 \u304c\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p><\/blockquote>\n<h3>\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u300c301 \/ 302 \/ 303 \/ 307\u300d\u306e\u9055\u3044\u306b\u3064\u3044\u3066<\/h3>\n<p>301 \/ 302\u3057\u304b\u77e5\u3089\u306a\u3044\u306e\u3067\u8abf\u3079\u305f\u3068\u3053\u308d\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u9055\u3044\u304c\u3042\u3063\u305f\u3002<\/p>\n<ul>\n<li>301 \u2192 \u6052\u4e45\u7684\u306a\u30ea\u30c0\u30a4\u30ec\u30af\u30c8<\/li>\n<li>302 \u2192 \u4e00\u6642\u7684\u306a\u30ea\u30c0\u30a4\u30ec\u30af\u30c8<\/li>\n<li>303 \u2192 \u4e00\u6642\u7684\u306a\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3002\u5c1a\u4e14\u3064\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u5148\u306b\u306fGET\u30e1\u30bd\u30c3\u30c9\u3067\u30ea\u30c0\u30a4\u30ec\u30af\u30c8<\/li>\n<li>307 \u2192 \u4e00\u6642\u7684\u306a\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3002\u5c1a\u4e14\u3064\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u5148\u306b\u306f\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u5143\u306e\u30e1\u30bd\u30c3\u30c9(GET \/ POST\u7b49)\u3092\u5f15\u304d\u7d99\u3044\u3067\u30ea\u30c0\u30a4\u30ec\u30af\u30c8<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>CodeIgniter4\u3067\u7279\u5b9a\u306e\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u304c\u3042\u3063\u305f\u969b\u306b301\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055 ... <\/p>\n","protected":false},"author":1,"featured_media":2517,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2,80],"tags":[],"class_list":["post-5449","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","category-codeigniter"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/5449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/comments?post=5449"}],"version-history":[{"count":2,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/5449\/revisions"}],"predecessor-version":[{"id":5473,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/5449\/revisions\/5473"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media\/2517"}],"wp:attachment":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media?parent=5449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/categories?post=5449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/tags?post=5449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}