<?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>url &#8211; VeriTeknik</title>
	<atom:link href="https://www.veriteknik.net.tr/en/tag/url/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.veriteknik.net.tr/en/</link>
	<description>VeriTeknik Bilişim &#124; VeriTeknik Bilişim</description>
	<lastBuildDate>Thu, 24 May 2012 14:38:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Apache mod_rewrite &#124; URL redirection with .htaccess</title>
		<link>https://www.veriteknik.net.tr/en/apache-mod_rewrite-url-redirection-with-htaccess/</link>
					<comments>https://www.veriteknik.net.tr/en/apache-mod_rewrite-url-redirection-with-htaccess/#respond</comments>
		
		<dc:creator><![CDATA[ckaraca]]></dc:creator>
		<pubDate>Thu, 24 May 2012 14:38:44 +0000</pubDate>
				<category><![CDATA[httpd]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[redirection]]></category>
		<category><![CDATA[url]]></category>
		<guid isPermaLink="false">http://www.plugged.in/?p=476</guid>

					<description><![CDATA[<p>Apache rewrite is an apache web server module which gives opportunity to change URL folders during opening of pages. At first it is hard to understand mod_rewrite but if you know what you are doing then it will become a usefull tool. You can reach the documents supplied by developer site located here: Apache Docs [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/apache-mod_rewrite-url-redirection-with-htaccess/">Apache mod_rewrite | URL redirection with .htaccess</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;">Apache rewrite is an apache web server module which gives opportunity to change URL folders during opening of pages. At first it is hard to understand mod_rewrite but if you know what you are doing then it will become a usefull tool. You can reach the documents supplied by developer site located here: <a title="Apache Documentation" href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" target="_blank">Apache Docs</a></p>
<p style="text-align: justify;">Usage areas of Apache mod_rewrite are:</p>
<ul>
<li>URL Redirect Ex: Redirection of plugged.in to www.plugged.in</li>
<li>Browser Redirect Ex: If Internet explorer is below version 7 then redirection to basic folder instead of high technology site</li>
<li>Bot Redirect, Ex: Redirection of Google bot for SEO optimization to a page which contains static links</li>
<li>Redirection to a different sun folder regarding to the browser language</li>
<li>To block out creating hotlinks of picture files Ex: You can prevent consuming bandwidth which is done by pictures used by other sites</li>
<li>SEO SEO Optimizationu, Ex: To show dynamic pages like php, aspx as static like .html</li>
</ul>
<p>used for purposes like above.</p>
<p>In order to use Apache Mod_rewrite, you must have the below instructions in the httpd.conf or in VirtualHost settings:</p>
<pre class="brush: bash; gutter: false; first-line: 1">OPTIONS  FollowSymLinks
# or
OPTIONS All
#and
AllowOverride All
#or
AllowOverride FileInfo</pre>
<p>You must create &#8220;.htaccess&#8221; file in the root folder of your web site in order to use mod_rewrite. There is always a point character in the begining of the secret files in the Unix systems, this is why htaccess can&#8217;t be seen through FTP applications. Because of this you should backup htaccess file locally if you only use ftp to store your files.<br />
.htaccess must begin with this description:</p>
<pre class="brush: bash; gutter: false; first-line: 1"># Apache must know the URLs which we change.
RewriteEngine On
# After that line, we will write the URLs to change</pre>
<p>Rewrite works like an algoritm, fist of all we should tell rewrite to change which requests. For this, we use RewriteCond command.</p>
<h4>RewriteCond command</h4>
<p><strong>Usage:</strong><br />
RewriteCond [Statement]+[NC]+[OR]
RewriteCond process the information like IP Address, site name, etc came from the browsers like Internet Explorer, Mozilla Firefox and Google Chrome.</p>
<p>These are the mostly used statements;<br />
<strong>REQUEST_FILENAME:</strong> Name of the requested page (ex. index.php)<br />
<strong>HTTP_USER_AGENT:</strong> Name of the used brwoser or bot(ex. For Firefox Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1 )<br />
<strong>QUERY_STRING:</strong> Statement after question mark (ex. index.php?page=anasayfa )<br />
<strong>SERVER_PROTOCOL:</strong> http or https<br />
<strong>HTTP_HOST:</strong> domain name<br />
<strong>THE_REQUEST:</strong> Requested page (ex. search.php )<br />
<strong>HTTP_REFERER:</strong> Site which requested page<br />
<strong>[NC]</strong> (No Case)<br />
This suffix provides non upper/lowercase sensitive statements.</p>
<p><strong>[OR]</strong> (or)<br />
To combine Multi RewriteCond statements.</p>
<h4>RewriteRule Statement</h4>
<p>You can specify how to write URL after existing condition, with this statement:<br />
<strong>[R]</strong> (push redirection)<br />
Redirected to external adress.</p>
<p><strong>[F]</strong> (forbiddenn)<br />
Redirected to page which indicates no permissions available to this page.</p>
<p><strong>[L]</strong> (last rule)<br />
Indicates that this statement is the last statement and no rule run after this point.</p>
<p>Let&#8217;s have a look at the examples to sort things up:</p>
<p><strong>Prevent hotlinking</strong></p>
<pre class="brush: bash; gutter: false; first-line: 1">RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$ [NC] # if no referrer
RewriteCond %{HTTP_REFERER} !^http://yoursitename.com [NC] # if the referrer is not your site
RewriteCond %{HTTP_REFERER} !^http://www.yoursitename.com [NC] # if the referrer is not your site
RewriteCond %{HTTP_REFERER} !^http://site_ip_address [NC] # if the referrer is not your sites ip
RewriteRule ^.*$ http://www.yoursitename.com/hotlink.jpg [R,L] # redirect to hotlink image</pre>
<p>or you can deny the request instead of redirecting to hotlink image:</p>
<pre class="brush: bash; gutter: false; first-line: 1">RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]</pre>
<p><strong>www redirection</strong></p>
<p><strong></strong>You can use the example below if one or more domain names like domain.com, seconddomain.com redirects to the same site:</p>
<pre class="brush: bash; gutter: false; first-line: 1">RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.sitename.com$ [NC]
RewriteRule ^(.*)$ http://www.sitename.com/$1 [R,L]</pre>
<h4 class="brush: bash; gutter: false; first-line: 1">Browser Redirection</h4>
<pre class="brush: bash; gutter: false; first-line: 1">It is used when there is differences between browsers while interpreting javascripts and css. Also you can redirect search engine bots such as googlebot to a page which is more plain but no javascript and css at all.By this way you may have a better ranking.</pre>
<pre class="brush: bash; gutter: false; first-line: 1">RewriteEngine On

# MS Internet Explorer - Mozilla v4
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4(.*)MSIE
RewriteRule ^index\.html$ /explorer.html [L]

# Chrome - Mozilla v5 - must be before Firefox rule
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5(.*)Chrome
RewriteRule ^index\.html$ /chrome.html [L]

# Firefox - Mozilla v5
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5(.*)Gecko
RewriteRule ^index\.html$ /firefox.html [L]

# Googlebot
RewriteCond %{HTTP_USER_AGENT} ^Googlebot/2(.*)googlebot
RewriteRule ^index\.html$ /google.html [L]

# Lynx or Mozilla v1/2
RewriteCond %{HTTP_USER_AGENT} ^Lynx/ [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/[12]
RewriteRule ^index\.html$ /resimsiz.html [L]

# others
RewriteRule ^index\.html$ /index.html [L]</pre>
<h4 class="brush: bash; gutter: false; first-line: 1">Several Home Pages based on Day time</h4>
<pre class="brush: bash; gutter: false; first-line: 1">RewriteEngine On
RewriteBase /

# 5:00 &gt; &lt; 8:00 funny code
RewriteCond %{TIME_HOUR} &gt;02
RewriteCond %{TIME_HOUR} &lt;05
RewriteRule ^index\\.html$ /morning.html

# 8:00 &gt; &lt; 16:00
RewriteCond %{TIME_HOUR} &gt;05
RewriteCond %{TIME_HOUR} &lt;13
RewriteRule ^index\\.html$ /day.html

# 16:00 &gt; &lt; 22:00
RewriteCond %{TIME_HOUR} &gt;13
RewriteCond %{TIME_HOUR} &lt;19
RewriteRule ^index\\.html$ /afternoon.html

# 22:00 &gt; &lt; 05:00
RewriteCond %{TIME_HOUR} &gt;19
RewriteCond %{TIME_HOUR} &lt;02
RewriteRule ^index\\.html$ /night.html</pre>
<h4 class="brush: bash; gutter: false; first-line: 1">HTTP to HTTPS Redirection</h4>
<p>In cases where you only want the checkout page to be SSL enabled.</p>
<pre class="brush: bash; gutter: false; first-line: 1">RewriteEngine on
rewritecond %{https} !^on$
rewritecond %{QUERY_STRING} checkout$ [NC]
RewriteRule .* https://sitename.com/checkout.php [R=301,L]</pre>
<h4 class="brush: bash; gutter: false; first-line: 1">Redirection based on Browser Language</h4>
<pre class="brush: bash; gutter: false; first-line: 1">RewriteEngine on

# English
RewriteCond %{HTTP:Accept-Language} ^en [NC]
RewriteRule ^$ /en/ [L,R=301]

# German
RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteRule ^$ /de/ [L,R=301]

# Spain
RewriteCond %{HTTP:Accept-Language} ^es [NC]
RewriteRule ^$ /es/ [L,R=301]

#All other languages
RewriteRule ^$ /default/ [L,R=301]</pre>
<h4 class="brush: bash; gutter: false; first-line: 1">Third level domain redirection to one site</h4>
<pre class="brush: bash; gutter: false; first-line: 1">You might have several domain names pointing the same site like yoursite.com and yoursite.com.au etc and you want to redirect all domain names to yoursite.com, here is the solution:</pre>
<pre class="brush: bash; gutter: false; first-line: 1">RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?yoursite.org [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?yoursite.info [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?yoursite.net [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?yoursite.com.au [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,NC, L]</pre>
<pre class="brush: bash; gutter: false; first-line: 1">.</pre>
<pre class="brush: bash; gutter: false; first-line: 1"></pre>
<pre class="brush: bash; gutter: false; first-line: 1"></pre>
<pre class="brush: bash; gutter: false; first-line: 1"></pre>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/apache-mod_rewrite-url-redirection-with-htaccess/">Apache mod_rewrite | URL redirection with .htaccess</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.veriteknik.net.tr/en/apache-mod_rewrite-url-redirection-with-htaccess/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">476</post-id>	</item>
	</channel>
</rss>
