Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This would be a good opportunity to teach yourself about HTTP status codes. Read the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10" rel="noreferrer">status code definitions section</a> of the HTTP 1.1 spec; section 10.3, "Redirection 3xx," covers the status codes pertinent to your question. Knowing the HTTP 3xx codes means that you can send a response that has exactly the semantics that you intend. For example, if you intend for the redirect to <em>always</em> occur, you could use HTTP 301, "Moved Permanently." In theory, a client could use the HTTP 301 response as a signal to store the new URL value in place of the old one.</p> <p>Your configuration options at Dreamhost are not as limited as you would think, because you can specify many Apache web server configuration directives in a hidden <strong>.htaccess</strong> file. This file should be placed in a web document directory; using your example, you would place it in the root web document directory, <em>/home/midas/codinghorror/</em>, though .htaccess files can be placed in any directory served by Apache. (Remember to include the leading dot in the filename.) Its contents would be either the mod_alias example or the mod_rewrite example already mentioned.</p> <p>Note that mod_alias's RedirectPermanent directive will send an HTTP 301 status code for you. If you wanted to use mod_rewrite to do this, you could specify the status code:</p> <pre><code>RewriteEngine on RewriteRule ^$ /blog/ [R=301] </code></pre> <p>If you use [R] without a code, then HTTP 302 ("Moved Temporarily") is used.</p> <p>Since PHP is also available to you, that's also an option, though it's possible that the above options using .htaccess are faster. You would place a file called index.php in <em>/home/midas/codinghorror/</em> and use the code given by Jeremy Ruten above. Again, you can specify a status code in the third argument to header():</p> <pre><code>&lt;?php header('Location: http://www.codinghorror.com/blog', TRUE, 301); ?&gt; </code></pre> <p>Otherwise, using PHP's header() function with 'Location' defaults to sending an HTTP 302 status response.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload