<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>CSSKarma &#187; meta</title> <atom:link href="http://www.csskarma.com/blog/tag/meta/feed/" rel="self" type="application/rss+xml" /><link>http://www.csskarma.com/blog</link> <description>display your style</description> <lastBuildDate>Tue, 31 Jan 2012 15:18:44 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Redirection Options</title><link>http://www.csskarma.com/blog/redirection-options/</link> <comments>http://www.csskarma.com/blog/redirection-options/#comments</comments> <pubDate>Wed, 27 Jan 2010 15:40:58 +0000</pubDate> <dc:creator>Tim</dc:creator> <category><![CDATA[Web Development]]></category> <category><![CDATA[beginner]]></category> <category><![CDATA[htaccess]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[meta]]></category> <category><![CDATA[php]]></category><guid
isPermaLink="false">http://www.csskarma.com/blog/?p=736</guid> <description><![CDATA[Lately, I&#8217;ve been having to work with a lot of redirects and I was going through different redirection options with a client. So I thought I would do a quick write up about the different types of redirection. I also haven&#8217;t seen a collection of these in one place, so I thought I would put [...]]]></description> <content:encoded><![CDATA[<p><img
src="http://www.csskarma.com/blog/wp-content/uploads/banner_redirection.png" alt="article banner"></p><p>Lately, I&#8217;ve been having to work with a lot of redirects and I was going through different redirection options with a client. So I thought I would do a quick write up about the <strong>different types of redirection</strong>.</p><p>I also haven&#8217;t seen a collection of these in one place, so I thought I would put this together.</p><p>There are a few different types that are commonly use when redirecting users:</p><ul><li>.htaccess / apache</li><li>php header</li><li>javascript</li><li>meta refresh</li></ul><p>The top two are the one&#8217;s you&#8217;ll be using most often, I don&#8217;t really recommend the last two. But they <em>are</em> available, so I think they&#8217;re worth noting. So here they are in the order I would recommend:</p><h3>.htaccess / apache redirects</h3><pre><code>Redirect /old_directory http://example.com/newdirectory</code></pre><p>This redirection is most efficient at the apache level, but if you&#8217;re like me and are on shared hosting, getting into the apache installation probably isn&#8217;t an option. In that case you can put this in an <a
href="http://www.csskarma.com/blog/creating-an-htaccess-template/">.htaccess file</a> in the root directory of your site.</p><p>Using an .htaccess redirection is great for moving entire sites because you can not only redirect a page, but you can redirect entire sites and subdirectories with one line of code.</p><h3>PHP header redirects</h3><pre><code>&lt;?php header('Location: http://example.com/newdirectory/'); ?&gt;</code></pre><p>PHP header redirects are good for single page redirects and if you&#8217;re not comfortable working with the .htaccess file. This code goes at the very top of the page you&#8217;re trying to redirect. If it&#8217;s not there you may get a &#8220;headers already sent&#8221; error.</p><p>If you&#8217;re publishing out static HTML files, you can still use this by adding this code into your .htaccess file:</p><pre><code>AddType application/x-httpd-php .php .html .htm</code></pre><p>This will let you <strong>execute PHP in an HTML file</strong>.</p><h3>JavaScript redirects</h3><pre><code>&lt;script type="text/javascript"&gt;
&lt;!--
window.location = "http://example.com/newdirectory"
//--&gt;
&lt;/script&gt;</code></pre><p>JavaScript redirects are generally not used unless you&#8217;ve exhausted the other two options. If you don&#8217;t have access to the .htaccess file AND you can&#8217;t run server-side script on your page, this is an OK fallback option, but you have to make sure to provide a link to the forwarding page incase a user is browsing without JavaScript.</p><h3>Meta redirects</h3><pre><code>&lt;meta http-equiv="refresh" content="0;URL=http://example.com/newdirectory"&gt;</code></pre><p>As your last option, I don&#8217;t see this in the wild anymore, but it&#8217;s worth mentioning that it does exist and does technically work (I&#8217;m not sure about it&#8217;s validity in HTML 5). You would place this in the document HEAD with the rest of the meta elements.</p><p>content=0 is a second timer for the redirect, I have this one set to 0 so it will redirect immediately.</p><p><strong>Those are the options I&#8217;ve used in the past; did I miss anything? Maybe an ASP redirect? Let me know!</strong></p> ]]></content:encoded> <wfw:commentRss>http://www.csskarma.com/blog/redirection-options/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 5/14 queries in 0.374 seconds using disk: basic

Served from: www.csskarma.com @ 2012-02-09 16:00:15 -->
