<?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>Make Money Blogging Tips For Free &#187; ModRewrite</title>
	<atom:link href="http://webmasterweblog.com/category/modrewrite/feed" rel="self" type="application/rss+xml" />
	<link>http://webmasterweblog.com</link>
	<description>Experiences of a Webmaster</description>
	<lastBuildDate>Mon, 01 Mar 2010 13:16:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>HTACCESS: Prevent Hotlinking by Referrer</title>
		<link>http://webmasterweblog.com/htaccess-prevent-hotlinking.html</link>
		<comments>http://webmasterweblog.com/htaccess-prevent-hotlinking.html#comments</comments>
		<pubDate>Fri, 05 Jun 2009 22:28:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ModRewrite]]></category>

		<guid isPermaLink="false">http://webmasterweblog.com/?p=171</guid>
		<description><![CDATA[Well, sometimes this becomes a REAL problem. As soon as your site becomes popular people will start to hotlink your stuff, copy it, post it wherever they can.
Most likely you will even find your stuff on sites like mininova, piratebay and other torrent sites.
Worst of all, they even direct link to your downloads and images and make your bandwitdh go up dramatically. 
So this time, we want to take a closer look on the htaccess file and fight!
Actually, many solutions out there are very very limited. Most people will only ...]]></description>
			<content:encoded><![CDATA[<p>Well, sometimes this becomes a REAL problem. As soon as your site becomes popular people will start to hotlink your stuff, copy it, post it wherever they can.<br />
Most likely you will even find your stuff on sites like mininova, piratebay and other torrent sites.<br />
Worst of all, they even direct link to your downloads and images and make your bandwitdh go up dramatically. </p>
<p>So this time, we want to take a closer look on the htaccess file and fight!<br />
Actually, many solutions out there are very very limited. Most people will only explain you how to prevent access to a file/folder completely or their solution does not work at all.</p>
<p>I was looking for a solution that would only allow direct access if the visitor would come from my own site and show up another image if they embed one of mine on their site.</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;">RewriteEngine on
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>HTTP_REFERER<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!</span>^http<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span>?<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//(www\.)?mymainurl.net [NC]</span>
RewriteRule \<span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span>jpg|jpeg|png|gif<span style="color: #009900;">&#41;</span>$ http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//mymainurl.net/angryman.gif [NC,R,L]</span>
&nbsp;
SetEnvIfNoCase Referer <span style="color: #0000ff;">&quot;^http://(www.)?url1.net&quot;</span> spam_ref<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span>
SetEnvIfNoCase Referer <span style="color: #0000ff;">&quot;^http://(www.)?url2.com&quot;</span> spam_ref<span style="color: #339933;">=</span><span style="color: #cc66cc;">2</span>
SetEnvIfNoCase Referer <span style="color: #0000ff;">&quot;^http://(www.)?google.com&quot;</span> spam_ref<span style="color: #339933;">=</span><span style="color: #cc66cc;">3</span>
<span style="color: #339933;">&lt;</span>filesmatch <span style="color: #0000ff;">&quot;(.rar)&quot;</span><span style="color: #339933;">&gt;</span>
order deny<span style="color: #339933;">,</span>allow
deny from all
allow from env<span style="color: #339933;">=</span>spam_ref
<span style="color: #339933;">&lt;/</span>filesmatch<span style="color: #339933;">&gt;</span></pre></div></div>

<p>This is it, the best working solution to prevent hotlinking. It will only give access to vistors from google or your own site, plus show an image of your choice when someone tried to put one of your images on their website.</p>
<p>You will have to modify it a bit. Simply add the file extensions to <filesmatch "(.rar)"> separated by &#8220;|&#8221;.<br />
Also change the referrers that are allowed to hotlink &#8220;SetEnvIfNoCase Referer&#8221;.<br />
Make sure to create an image called &#8220;angryman.gif&#8221; that will show up on other sites. It should contain your URL and a funny line to make the user enter the URL and leave the current website. </p>
]]></content:encoded>
			<wfw:commentRss>http://webmasterweblog.com/htaccess-prevent-hotlinking.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache &#8220;Under Construction&#8221; with exceptions</title>
		<link>http://webmasterweblog.com/apache-under-construction-with-exceptions.html</link>
		<comments>http://webmasterweblog.com/apache-under-construction-with-exceptions.html#comments</comments>
		<pubDate>Tue, 02 Dec 2008 13:52:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ModRewrite]]></category>

		<guid isPermaLink="false">http://webmasterweblog.com/?p=122</guid>
		<description><![CDATA[Do you want to restrict access to certain folders only ?
Usually you will put a .htaccess into your main dir if your site should not be accesible to the public. That&#8217;s how you can easily avoid that it will get indexed by search engine spiders for example.

You would do it like this:

AuthType Basic
AuthName &#34;Restricted Directory&#34;
AuthUserFile /path/to/my/.htusers
Require valid-user

Then you just need a .htusers (google for htusers generator if you don&#8217;t know how to generate one) and people won&#8217;t be able to see your site content at all. 
On the downside you ...]]></description>
			<content:encoded><![CDATA[<p>Do you want to restrict access to certain folders only ?<br />
Usually you will put a .htaccess into your main dir if your site should not be accesible to the public. That&#8217;s how you can easily avoid that it will get indexed by search engine spiders for example.<br />
<span id="more-122"></span><br />
You would do it like this:</p>

<div class="wp_syntax"><div class="code"><pre class="modrewrite" style="font-family:monospace;">AuthType Basic
AuthName &quot;Restricted Directory&quot;
AuthUserFile /path/to/my/.htusers
Require valid-user</pre></div></div>

<p>Then you just need a .htusers (google for htusers generator if you don&#8217;t know how to generate one) and people won&#8217;t be able to see your site content at all. </p>
<p>On the downside you can&#8217;t access any subdirectories! If you want to specify any exceptions simply put a .htaccess file into the folder and insert &#8220;Satisfy any&#8221; into it. Done! Now you can access the subdirectories but not the main directory. </p>
]]></content:encoded>
			<wfw:commentRss>http://webmasterweblog.com/apache-under-construction-with-exceptions.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rewrite uppercase URL&#8217;s to lowercase</title>
		<link>http://webmasterweblog.com/rewrite-uppercase-to-lowercase.html</link>
		<comments>http://webmasterweblog.com/rewrite-uppercase-to-lowercase.html#comments</comments>
		<pubDate>Mon, 20 Oct 2008 16:57:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ModRewrite]]></category>

		<guid isPermaLink="false">http://webmasterweblog.com/?p=117</guid>
		<description><![CDATA[Well today I had to rewrite some URL&#8217;s from upper to lower-case letters. Somehow it did not rewrite this automatically. I didn&#8217;t figure out the reason why it did not work properly but I found a workaround.
If you have access to the httpd.conf file of the apache server, then simply add the following lines:

&#60;VirtualHost IP:80&#62;
&#160;
   stuff here
&#160;
   &#60;IfModule mod_rewrite.c&#62;
   RewriteEngine on
   rewritemap lowercase int:tolower
   RewriteCond $1 [A-Z]
   RewriteRule ^/(.*)$ /${lowercase:$1} [R=301,L] 
   &#60;/IfModule&#62;

Now it will redirect ...]]></description>
			<content:encoded><![CDATA[<p>Well today I had to rewrite some URL&#8217;s from upper to lower-case letters. Somehow it did not rewrite this automatically. I didn&#8217;t figure out the reason why it did not work properly but I found a workaround.</p>
<p>If you have access to the httpd.conf file of the apache server, then simply add the following lines:</p>

<div class="wp_syntax"><div class="code"><pre class="apache apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> IP:<span style="color: #ff0000;">80</span>&gt;
&nbsp;
   stuff here
&nbsp;
   &lt;<span style="color: #000000; font-weight:bold;">IfModule</span> mod_rewrite.c&gt;
   <span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">on</span>
   <span style="color: #00007f;">rewritemap</span> lowercase int:tolower
   <span style="color: #00007f;">RewriteCond</span> $<span style="color: #ff0000;">1</span> [A-Z]
   <span style="color: #00007f;">RewriteRule</span> ^/(.*)$ /${lowercase:$<span style="color: #ff0000;">1</span>} [R=<span style="color: #ff0000;">301</span>,L] 
   &lt;/<span style="color: #000000; font-weight:bold;">IfModule</span>&gt;</pre></div></div>

<p>Now it will redirect the URL&#8217;s properly. Yay!<br />
<a href="http://www.webmasterworld.com/forum92/5308.htm" >Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://webmasterweblog.com/rewrite-uppercase-to-lowercase.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirect root to folder</title>
		<link>http://webmasterweblog.com/redirect-root-to-folder.html</link>
		<comments>http://webmasterweblog.com/redirect-root-to-folder.html#comments</comments>
		<pubDate>Mon, 12 May 2008 21:09:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ModRewrite]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[root dir]]></category>

		<guid isPermaLink="false">http://webmasterweblog.com/redirect-root-to-folder/</guid>
		<description><![CDATA[If you want to redirect your root site to a subfolder then the following code can help you:
RedirectMatch  ^/$ http://name.com/forums/
Add that to your .htaccess file after &#8220;RewriteEngine On&#8221;.
The ^ is a regular expression and stands for the the start string, the $ stands for the end string.
If you are new to RegEx I recommend the Regular Expression  ]]></description>
			<content:encoded><![CDATA[<p>If you want to redirect your root site to a subfolder then the following code can help you:<br />
<code>RedirectMatch  ^/$ http://name.com/forums/</code><br />
Add that to your .htaccess file after &#8220;RewriteEngine On&#8221;.<br />
The ^ is a regular expression and stands for the the start string, the $ stands for the end string.<br />
If you are new to RegEx I recommend the Regular Expression  <a href="http://www.ilovejackdaniels.com/regular_expressions_cheat_sheet.pdf target=" _blank">Cheat Sheet</a>! </p>
]]></content:encoded>
			<wfw:commentRss>http://webmasterweblog.com/redirect-root-to-folder.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hide Folder Directory</title>
		<link>http://webmasterweblog.com/hide-folder-directory.html</link>
		<comments>http://webmasterweblog.com/hide-folder-directory.html#comments</comments>
		<pubDate>Mon, 12 May 2008 21:01:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ModRewrite]]></category>
		<category><![CDATA[hide directory]]></category>
		<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://webmasterweblog.com/hide-folder-directory/</guid>
		<description><![CDATA[If you want to hide your directory index so that people can&#8217;t see your files if they open a directory without a index file you have to add this to your .htaccess
Options -Indexes
]]></description>
			<content:encoded><![CDATA[<p>If you want to hide your directory index so that people can&#8217;t see your files if they open a directory without a index file you have to add this to your .htaccess<br />
<code>Options -Indexes</code></p>
]]></content:encoded>
			<wfw:commentRss>http://webmasterweblog.com/hide-folder-directory.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rewriting &#8220;www&#8221; to &#8220;non-ww&#8221; Domain</title>
		<link>http://webmasterweblog.com/rewrite-www-to-non-www.html</link>
		<comments>http://webmasterweblog.com/rewrite-www-to-non-www.html#comments</comments>
		<pubDate>Sat, 22 Mar 2008 04:18:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ModRewrite]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[non-www]]></category>
		<category><![CDATA[www domain]]></category>

		<guid isPermaLink="false">http://vistadesktopthemes.com/vista-theme-1/</guid>
		<description><![CDATA[Due to SEO aspects many webmasters rewrite all their &#8220;www&#8221; queries to &#8220;non-www&#8221; queries. Why that ? Simply because search engines might think there is duplicate content if they can access www.yourdomain.com and http://yourdomain.com at the same time.
That&#8217;s why you should rewrite www to non-www or vice versa permanently.
Here is the simple solution for that:
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^yourdomain\.com
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]




Personally I think the shorter the better, but it&#8217;s different for each target group. Older people sometimes think that you have to type www in front of any domain ...]]></description>
			<content:encoded><![CDATA[<p>Due to SEO aspects many webmasters rewrite all their &#8220;www&#8221; queries to &#8220;non-www&#8221; queries. Why that ? Simply because search engines might think there is duplicate content if they can access www.yourdomain.com and http://yourdomain.com at the same time.</p>
<p>That&#8217;s why you should rewrite www to non-www or vice versa permanently.</p>
<p><strong>Here is the simple solution for that:</strong></p>
<p>RewriteCond %{HTTP_HOST} .<br />
RewriteCond %{HTTP_HOST} !^yourdomain\.com<br />
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3156464024075139";
/* 336x280, Erstellt 06.10.08 */
google_ad_slot = "4864146005";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Personally I think the shorter the better, but it&#8217;s different for each target group. Older people sometimes think that you have to type www in front of any domain name. This is completely up to you! Enjoy rewriting <img src='http://webmasterweblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://webmasterweblog.com/rewrite-www-to-non-www.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
