{"id":10054,"date":"2021-05-14T17:13:44","date_gmt":"2021-05-14T14:13:44","guid":{"rendered":"https:\/\/unihost.com\/help\/?p=10054"},"modified":"2023-01-19T13:48:20","modified_gmt":"2023-01-19T10:48:20","slug":"how-to-configure-a-301-redirect","status":"publish","type":"post","link":"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/","title":{"rendered":"How to configure a 301 redirect"},"content":{"rendered":"<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">In this tutorial, we&#8217;ll take a look at 301 redirects for NGINX and Apache web servers.<!--more--><\/span><\/p>\n<h3 align=\"center\"><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">NGINX<\/span><\/h3>\n<h4><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><strong>Method No. 1&nbsp;is a line:<\/strong><\/span><\/h4>\n<pre align=\"justify\"><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server {<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">rewrite ^ https:\/\/$host$request_uri? &lt;flag&gt;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">}<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Here the <strong><em>$host<\/em><\/strong> &#8211; variable is the host from the requests. If it is absent, you should use the header name in the &#8220;Host&#8221; field, if it is not there, the server name will do.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">The <strong><em>$request_uri<\/em><\/strong> &#8211; variable is the initial request with arguments.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">When configuring, the following flags (&lt;flag&gt;) can be selected:<\/span><\/p>\n<ul>\n<li><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><strong>permanent<\/strong> &#8211; 301 redirect (or permanent redirect) to a page with a 301 server response code.<\/span><\/li>\n<li><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><strong>redirect<\/strong> &#8211; a 302 redirect (or temporary redirect) to a page with a 302 code.<\/span><\/li>\n<li><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><strong>last<\/strong> &#8211; completion of processing and subsequent transition to a new location.<\/span><\/li>\n<li><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><strong>break<\/strong> &#8211; completion of processing and work in the current location.<\/span><\/li>\n<\/ul>\n<h4><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><strong>Method No. 2<\/strong><\/span><\/h4>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">return &lt;code&gt; https:\/\/$host$request_uri;<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Any redirect code can be used here, however, the most common cases are 301, 302, 404.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">After finishing editing the files, it remains to check if they are correct:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">nginx -t<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">To apply them, you need to restart Nginx:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">systemctl restart nginx<\/span><\/pre>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Practical examples of redirects<\/span><\/h5>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Redirect from www to without www<\/span><\/h5>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">This is the most common redirect and allows all traffic to be directed directly to the domain, bypassing subdomains. Redirect code:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"># www.domen -&gt; domen<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server {<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server_name www.[domain];<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">return 301 $scheme:\/\/[domain]$request_uri;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">}<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">If you want to get the opposite effect (redirect to &#8220;www&#8221; without www&#8221;):<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server {<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server_name [domain];<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">return 301 $scheme:\/\/www.[domain]$request_uri;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">}<\/span><\/pre>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Redirect to another domain<\/span><\/h5>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">To organize a redirect to another site &#8211; for example, after changing the site address &#8211; you can use the command:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">location \/ {<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">rewrite ^(.*)$ $scheme:\/\/new-domain.com\/$1 redirect;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">}<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">The second option is simpler:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">location \/ {<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">return 301 $scheme:\/\/$http_host$request_uri;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">}<\/span><\/pre>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Redirect from http to https<\/span><\/h5>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">You can set up a redirect from HTTP to HTTPS (SSL secure protocol) as follows:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server {<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">listen 80;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server_name domain.com www.domain.com;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">return 301 https:\/\/$host$request_uri;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">}<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Here, for all requests to domain.com via the HTTP protocol, a redirect to port 443 will be triggered using a 301 redirect to merge domains.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">To set up a redirect to HTTP from HTTPS, just change the server response code:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server {<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">listen 443;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server_name domain.com www.domain.com;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">return 301 http:\/\/$host$request_uri;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">}<\/span><\/pre>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Redirect to another server<\/span><\/h5>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">If necessary, redirect all requests to another server:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">location \/ {<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">proxy_pass $scheme:\/\/192.168.0.12:8080\/;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">proxy_redirect off;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">proxy_set_header Host $host;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">proxy_set_header X-Real-IP $remote_addr;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">}<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Here, the Nginx web server is responsible for accepting and responding to browser requests. They are processed by the server with the IP address 192.168.0.12 (port 8080). Redirecting to another Nginx is done in the same way.<\/span><\/p>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Redirect from IP address to domain<\/span><\/h5>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server {<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">listen 80;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server_name 192.168.1.15;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">return 301 http:\/\/site.ru$request_uri;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">}<\/span><\/pre>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Redirect multiple domains to one directory and one main domain<\/span><\/h5>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">This trick comes in handy when you have multiple domains. Let&#8217;s take the following domains as an example:<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">example-domain.net<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">example-domain.com<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">example-domain.org<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">All of these domains point to the same directory on the server. Accordingly, they display the same page\/content, albeit when entering different addresses.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Do not forget about the exception of the 404 error (&#8220;page not found&#8221;), which may occur if someone uses a link to a product\/page from one of the alternative domains. You can solve this problem in the following way:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server {<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">server_name example-domain.net example-domain.com example-domain.org;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">rewrite ^ http:\/\/example-domain.net$request_uri? permanent;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">}<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Thus, all alternative addresses other than &#8220;.net&#8221; will be directed to &#8220;example-domain.net&#8221;, which is the primary address.<\/span><\/p>\n<h3 style=\"text-align: center;\"><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Apache<\/span><\/h3>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">All rules are executed in the direct order in which they appear in the .htaccess file, and a rule written later will be executed later.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><strong>.htaccess<\/strong> is an additional configuration file for the Apache webserver that can be used to configure settings at the level of individual directories. Unlike the main configuration file <strong><em>httpd.conf<\/em><\/strong>, directives in .htaccess apply only to the directory where it is located and to child directories.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Below are the most commonly used rules for configuring the .htaccess file for a 301 redirect. It is better to place all rules after two lines:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Options +FollowSymLinks<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">RewriteEngine On<\/span><\/pre>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Domain redirect from WWW to a without WWW domain<\/span><\/h5>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">RewriteCond %{HTTP_HOST} ^http:\/\/www.example\\.com$ [NC]<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">RewriteRule ^(.*)$ http:\/\/example.com\/$1[R=301,L]<\/span><\/pre>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Standard redirect from one static page to another<\/span><\/h5>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Redirect 301 \/was.php http:\/\/example.com\/new.php<\/span><\/pre>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Configuring redirects from HTTP to HTTPS (for all pages)<\/span><\/h5>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">RewriteCond %{SERVER_PORT} ^80$ [OR]<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">RewriteCond %{HTTP} =on<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">RewriteRule ^(.*)$ https:\/\/example.com\/$1 [R=301,L]<\/span><\/pre>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">301-redirect from domain to domain<\/span><\/h5>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">RewriteCond %{HTTP_HOST} ^old-site\\.com$ [NC]<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">RewriteRule ^(.*)$ http:\/\/www.example.com\/$1 [R=301,L]<\/span><\/pre>\n<h5><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Specifying the path to the 404 error file using .htaccess<\/span><\/h5>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Note, it is important that the server response code for a 404 error is exactly 404. The path to the file is indicated using the following line:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">ErrorDocument 404 \/404-for-me.php<\/span><\/pre>\n<h5 style=\"text-align: center;\"><span style=\"font-family: Ubuntu, sans-serif;\">The reminder on the symbols and designation used.<\/span><\/h5>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">The RewriteCond line is a condition for executing the RewriteRule. If the condition is met, then the redirect is triggered. Rules can be specified using regular expressions.<\/span><\/p>\n<h6><strong><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Special characters used in rules and their meanings.<\/span><\/strong><\/h6>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">^ &#8211; the special character of the beginning of a line;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">$ &#8211; end of line special character;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">! &#8211; special negation character;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">&#8230; &#8211; point, replaces any character, but only one;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">() &#8211; grouping;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">\\ &#8211; &#8220;escape&#8221; slash, the next character after it is considered a normal, not a special character;<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"># &#8211; the beginning of a text comment in the file.<\/span><\/p>\n<h6><strong><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Modifiers are used after ordinary, special characters or their groups and allow you to expand the capabilities of templates for triggering rules.<\/span><\/strong><\/h6>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">? &#8211; the character is repeated 0 or 1 times.<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">+ &#8211; repeats from 1 to 65536 times.<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">* &#8211; repeats from 0 to 65536 times.<\/span><\/p>\n<h6><strong><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Flags set additional options for the used rule. Listed in square brackets, separated by commas, say [NC] or [R = 301, L].<\/span><\/strong><\/h6>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">NC &#8211; NoCase flag that disables case checking when the rule is triggered.<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">R &#8211; the Redirect flag, performs the process of stopping the URL change and returns the result. The most commonly used value is R = 301, but others are possible for temporary redirects (302, MOVED TEMPORARY).<\/span><br><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">L &#8211; Last flag, stops URL generation and the string is considered final.<\/span><\/p>\n<p><\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we&#8217;ll take a look at 301 redirects for NGINX and Apache web servers.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[158],"tags":[690,447,626,689],"class_list":["post-10054","post","type-post","status-publish","format-standard","hentry","category-dedicated-servers","tag-301-2","tag-apache-2","tag-nginx-2","tag-redirect-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to configure a 301 redirect - Unihost.FAQ<\/title>\n<meta name=\"description\" content=\"\u2714 A step by step tutorial: How to configure a 301 redirect for NGINX and Apache web servers. - Unihost.FAQ\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to configure a 301 redirect - Unihost.FAQ\" \/>\n<meta property=\"og:description\" content=\"\u2714 A step by step tutorial: How to configure a 301 redirect for NGINX and Apache web servers. - Unihost.FAQ\" \/>\n<meta property=\"og:url\" content=\"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/\" \/>\n<meta property=\"og:site_name\" content=\"Unihost.FAQ\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/unihost\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-14T14:13:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-19T10:48:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/unihost.com\/help\/minio.php?.\/unihost-logo-alt.png\" \/>\n\t<meta property=\"og:image:width\" content=\"250\" \/>\n\t<meta property=\"og:image:height\" content=\"141\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Unihost Support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@unihost\" \/>\n<meta name=\"twitter:site\" content=\"@unihost\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Unihost Support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/\"},\"author\":{\"name\":\"Unihost Support\",\"@id\":\"https:\/\/unihost.com\/help\/#\/schema\/person\/bb5ae95f38577c920e6a7507888b715a\"},\"headline\":\"How to configure a 301 redirect\",\"datePublished\":\"2021-05-14T14:13:44+00:00\",\"dateModified\":\"2023-01-19T10:48:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/\"},\"wordCount\":852,\"publisher\":{\"@id\":\"https:\/\/unihost.com\/help\/#organization\"},\"keywords\":[\"301\",\"Apache\",\"Nginx\",\"redirect\"],\"articleSection\":[\"02. Dedicated servers\"],\"inLanguage\":\"en\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/\",\"url\":\"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/\",\"name\":\"How to configure a 301 redirect - Unihost.FAQ\",\"isPartOf\":{\"@id\":\"https:\/\/unihost.com\/help\/#website\"},\"datePublished\":\"2021-05-14T14:13:44+00:00\",\"dateModified\":\"2023-01-19T10:48:20+00:00\",\"description\":\"\u2714 A step by step tutorial: How to configure a 301 redirect for NGINX and Apache web servers. - Unihost.FAQ\",\"breadcrumb\":{\"@id\":\"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/#breadcrumb\"},\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Unihost\",\"item\":\"https:\/\/unihost.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Help\",\"item\":\"https:\/\/unihost.com\/help\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to configure a 301 redirect\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/unihost.com\/help\/#website\",\"url\":\"https:\/\/unihost.com\/help\/\",\"name\":\"Unihost.FAQ\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/unihost.com\/help\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/unihost.com\/help\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/unihost.com\/help\/#organization\",\"name\":\"Unihost\",\"alternateName\":\"Unihost\",\"url\":\"https:\/\/unihost.com\/help\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\/\/unihost.com\/help\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/unihost.com\/help\/minio.php?2026\/01\/minio.png\",\"contentUrl\":\"https:\/\/unihost.com\/help\/minio.php?2026\/01\/minio.png\",\"width\":300,\"height\":300,\"caption\":\"Unihost\"},\"image\":{\"@id\":\"https:\/\/unihost.com\/help\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/unihost\/\",\"https:\/\/x.com\/unihost\",\"https:\/\/www.instagram.com\/unihost\/?hl=en\",\"https:\/\/www.linkedin.com\/company\/unihost-com\",\"https:\/\/www.youtube.com\/channel\/UCITKsxMDnslQY8brN3advgw\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/unihost.com\/help\/#\/schema\/person\/bb5ae95f38577c920e6a7507888b715a\",\"name\":\"Unihost Support\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\/\/unihost.com\/help\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a0c9db17c2a0d93e8a0d5ac123f8c5db750ad4d3d5657369c0c4e480f5af77b8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a0c9db17c2a0d93e8a0d5ac123f8c5db750ad4d3d5657369c0c4e480f5af77b8?s=96&d=mm&r=g\",\"caption\":\"Unihost Support\"},\"sameAs\":[\"https:\/\/unihost.com\/\"],\"url\":\"https:\/\/unihost.com\/help\/author\/support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to configure a 301 redirect - Unihost.FAQ","description":"\u2714 A step by step tutorial: How to configure a 301 redirect for NGINX and Apache web servers. - Unihost.FAQ","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/","og_locale":"en_US","og_type":"article","og_title":"How to configure a 301 redirect - Unihost.FAQ","og_description":"\u2714 A step by step tutorial: How to configure a 301 redirect for NGINX and Apache web servers. - Unihost.FAQ","og_url":"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/","og_site_name":"Unihost.FAQ","article_publisher":"https:\/\/www.facebook.com\/unihost\/","article_published_time":"2021-05-14T14:13:44+00:00","article_modified_time":"2023-01-19T10:48:20+00:00","og_image":[{"width":250,"height":141,"url":"https:\/\/unihost.com\/help\/minio.php?.\/unihost-logo-alt.png","type":"image\/png"}],"author":"Unihost Support","twitter_card":"summary_large_image","twitter_creator":"@unihost","twitter_site":"@unihost","twitter_misc":{"Written by":"Unihost Support","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/#article","isPartOf":{"@id":"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/"},"author":{"name":"Unihost Support","@id":"https:\/\/unihost.com\/help\/#\/schema\/person\/bb5ae95f38577c920e6a7507888b715a"},"headline":"How to configure a 301 redirect","datePublished":"2021-05-14T14:13:44+00:00","dateModified":"2023-01-19T10:48:20+00:00","mainEntityOfPage":{"@id":"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/"},"wordCount":852,"publisher":{"@id":"https:\/\/unihost.com\/help\/#organization"},"keywords":["301","Apache","Nginx","redirect"],"articleSection":["02. Dedicated servers"],"inLanguage":"en"},{"@type":"WebPage","@id":"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/","url":"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/","name":"How to configure a 301 redirect - Unihost.FAQ","isPartOf":{"@id":"https:\/\/unihost.com\/help\/#website"},"datePublished":"2021-05-14T14:13:44+00:00","dateModified":"2023-01-19T10:48:20+00:00","description":"\u2714 A step by step tutorial: How to configure a 301 redirect for NGINX and Apache web servers. - Unihost.FAQ","breadcrumb":{"@id":"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/unihost.com\/help\/how-to-configure-a-301-redirect\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Unihost","item":"https:\/\/unihost.com\/"},{"@type":"ListItem","position":2,"name":"Help","item":"https:\/\/unihost.com\/help\/"},{"@type":"ListItem","position":3,"name":"How to configure a 301 redirect"}]},{"@type":"WebSite","@id":"https:\/\/unihost.com\/help\/#website","url":"https:\/\/unihost.com\/help\/","name":"Unihost.FAQ","description":"","publisher":{"@id":"https:\/\/unihost.com\/help\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/unihost.com\/help\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/unihost.com\/help\/#organization","name":"Unihost","alternateName":"Unihost","url":"https:\/\/unihost.com\/help\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/unihost.com\/help\/#\/schema\/logo\/image\/","url":"https:\/\/unihost.com\/help\/minio.php?2026\/01\/minio.png","contentUrl":"https:\/\/unihost.com\/help\/minio.php?2026\/01\/minio.png","width":300,"height":300,"caption":"Unihost"},"image":{"@id":"https:\/\/unihost.com\/help\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/unihost\/","https:\/\/x.com\/unihost","https:\/\/www.instagram.com\/unihost\/?hl=en","https:\/\/www.linkedin.com\/company\/unihost-com","https:\/\/www.youtube.com\/channel\/UCITKsxMDnslQY8brN3advgw"]},{"@type":"Person","@id":"https:\/\/unihost.com\/help\/#\/schema\/person\/bb5ae95f38577c920e6a7507888b715a","name":"Unihost Support","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/unihost.com\/help\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a0c9db17c2a0d93e8a0d5ac123f8c5db750ad4d3d5657369c0c4e480f5af77b8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a0c9db17c2a0d93e8a0d5ac123f8c5db750ad4d3d5657369c0c4e480f5af77b8?s=96&d=mm&r=g","caption":"Unihost Support"},"sameAs":["https:\/\/unihost.com\/"],"url":"https:\/\/unihost.com\/help\/author\/support\/"}]}},"_links":{"self":[{"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/posts\/10054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/comments?post=10054"}],"version-history":[{"count":14,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/posts\/10054\/revisions"}],"predecessor-version":[{"id":10507,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/posts\/10054\/revisions\/10507"}],"wp:attachment":[{"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/media?parent=10054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/categories?post=10054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/tags?post=10054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}