<?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>Website Design Ireland, Website Development &#187; url rewrite</title>
	<atom:link href="http://www.eire-webdesign.ie/blog/tag/url-rewrite/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.eire-webdesign.ie/blog</link>
	<description>Web Design and Development</description>
	<lastBuildDate>Sat, 02 Jan 2010 14:53:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>URL rewrite tips and solutions</title>
		<link>http://www.eire-webdesign.ie/blog/2007/12/07/url-rewrite-tips-and-solutions/</link>
		<comments>http://www.eire-webdesign.ie/blog/2007/12/07/url-rewrite-tips-and-solutions/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 11:53:54 +0000</pubDate>
		<dc:creator>Louie @ Eire Web Design</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[url rewrite]]></category>

		<guid isPermaLink="false">http://www.eire-webdesign.ie/blog/2007/12/07/url-rewrite-tips-and-solutions/</guid>
		<description><![CDATA[Due to server setup and having no access to the php.ini file to change your server settings, we will resume to the .htaccess file for rewriting the URL, removing or adding the www. and removing the PHPSESSID from the URL itself to prevent duplicated content into the Search Engines, so here are few tips to [...]]]></description>
			<content:encoded><![CDATA[<p>Due to server setup and having no access to the php.ini file to change your server settings, we will resume to the .htaccess file for rewriting the URL, removing or adding the www. and removing the PHPSESSID from the URL itself to prevent duplicated content into the Search Engines, so here are few tips to get you started:</p>
<p>First lets create a new file and name it .htaccess (only if you don&#8217;t already have one), and ad the following lines at the very top:</p>
<pre lang="php">
Options +FollowSymlinks
RewriteEngine on
RewriteBase /</pre>
<p>Now we are going to check the URL making sure the www. is always there otherwise we will redirect to the right format URL:</p>
<pre lang="php">
# redirect if not www
RewriteCond %{HTTP_HOST} !^(www)\.domain-name\.ie  

RewriteRule ^(.*)$ http://www.domain-name.ie/$1 [R=301,L]</pre>
<p>Now lets redirect the index.php or .html to the main URL as this creates duplicated content as well:</p>
<pre lang="php">
#redirect index.php or htm to /
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(htm|html|php)\ HTTP  

RewriteRule ^(.*)index\.(htm|html|php)$ /$1 [R=301,L]</pre>
<p>Depending on your server settings, sometimes the PHPSESSID get attached to the end of your URL, which will also created duplicated content, so there is a solution written in php that will check for the PHPSESSID query-string and if found, we will remove it and do a 301 Permanent Redirect to the same page but without it:</p>
<pre lang="php">
//remove session id from url  

if (!empty($_GET['PHPSESSID'])) {  

  $clean_uri = preg_replace('/?PHPSESSID=[^&amp;]+/','',$_SERVER['REQUEST_URI']);  

  $clean_uri = preg_replace('/&amp;PHPSESSID=[^&amp;]+/','',$clean_uri );  

    header('HTTP/1.1 301 Moved Permanently');  

  header('Location: http://'.$_SERVER['HTTP_HOST'] . $clean_uri );  

    exit();  

}  

//</pre>
<p>Please Note: The above solution is not part of the .htaccess file, but has to be added to a common include file available across the site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.eire-webdesign.ie/blog/2007/12/07/url-rewrite-tips-and-solutions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

