<?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>LAMP with ·dotmanila &#187; force trailing slash</title>
	<atom:link href="http://dotmanila.com/blog/tag/force-trailing-slash/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotmanila.com/blog</link>
	<description>Linux, Apache, PHP, MySQL Musings</description>
	<lastBuildDate>Wed, 01 Feb 2012 23:32:54 +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>Cloak PHP Files as Directories and Force Trailing Slash via mod_rewrite</title>
		<link>http://dotmanila.com/blog/2009/05/cloak-php-files-as-directories-and-force-trailing-slash-via-mod_rewrite/</link>
		<comments>http://dotmanila.com/blog/2009/05/cloak-php-files-as-directories-and-force-trailing-slash-via-mod_rewrite/#comments</comments>
		<pubDate>Wed, 06 May 2009 11:43:51 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[force trailing slash]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[php cloaking]]></category>
		<category><![CDATA[Search Engine Optimization]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=50</guid>
		<description><![CDATA[In an effort to turn a client's website to be more SEO friendly, they wanted to have all PHP files appear as directories on URLs i.e. http://dotmanila.com/blog/php-cloak-and-force-traling-slash.php will end up as http://dotmanila.com/blog/php-cloak-and-force-traling-slash/. We've thought of creating a simple controller combined with mod_rewrite to handle this change on their 30+ websites, however it'll be inefficient to use a two-fold process. So we toyed with mod_rewrite and came up below.]]></description>
			<content:encoded><![CDATA[<p>In an effort to turn a client&#8217;s website to be more SEO friendly, they wanted to have all PHP files appear as directories on URLs i.e. http://dotmanila.com/blog/php-cloak-and-force-traling-slash.php will end up as http://dotmanila.com/blog/php-cloak-and-force-traling-slash/. We&#8217;ve thought of creating a simple controller combined with mod_rewrite to handle this change on their 30+ websites, however it&#8217;ll be inefficient to use a two-fold process. So we toyed with mod_rewrite and came up below.</p>
<pre class="brush: text; ruler: true;">
Options +FollowSymLinks
RewriteEngine On

RewriteBase /

# These first set of rules makes sure that visitors
# are viewing the WWW domain i.e. www.dotmanila.com
Rewritecond %{HTTP_HOST} !^www\.dotmanila\.com
RewriteRule (.*) http://www.dotmanila.com/$1/ [R=301,L]

# The next set of rules checks that if the URL
# does not have a trailing slash and
# the requested file/directory when appended
# with the .php extension physically exist on the server
# the we will append a traling slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.dotmanila.com/$1/ [L,R=301]

# The last set of rules makes sure that if
# the requested URL is in proper format the
# corresponding PHP file is mapped.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)/$ /$1.php [NS,L]</pre>
</pre>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2009/05/cloak-php-files-as-directories-and-force-trailing-slash-via-mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

