Archive for the 'Apache' Category

YTM launch!!

No more beta for YouTellMe.nl
The website which is taking over the Dutch product comparison market is officially going out of beta @ 8 o clock.
Party in Amsterdam, Keizersgracht 182 :) Festivities starting right now!

13342_350348980430_784785430_9966158_5558110_n

Things are going well, looking very forward to international launch.
We’ve changed a lot since the first reviews!

13342_350352790430_784785430_9966172_7726367_n

Beter pictures coming after the event :P

PS. Thanks to Python and Django, for enabling us to beat the competition :)

PSS. Next2News, eduhub, come and join :)

Apache & Business & Css & Django & Dutch & Events & Javascript & PHP & Prototype & Python & Symfony & Web Development & YouTellMe tschellenbach 11 Dec 2009 1 Comment

Setting up .htaccess for Wordpress

Usually .htaccess for Wordpress is set automatically when you change the permalink settings.

Unfortunately for me the Wordpress system was not working properly. When I wrote the first posts on this blog however I did not bother to deal with the issue. Doing so leaves you with two problems:

  1. How to set .htaccess
  2. How to ensure the links to your old posts get redirected

After reading the great mod_rewrite documentation and combining that with a great .htaccess files here my solution.

In order to deal with the old posts:

RewriteCond %{QUERY_STRING} ^p=11$
RewriteRule ^$ http://www.mellowmorning.com/2007/08/27/picture-resizing-on-steroids/? [R=301,L]
RewriteCond %{QUERY_STRING} ^p=3$
RewriteRule ^$ http://www.mellowmorning.com/2007/08/18/ten-reasons-why-symfony-rocks-part-1/? [R=301,L]
RewriteCond %{QUERY_STRING} ^p=4$
RewriteRule ^$ http://www.mellowmorning.com/2007/08/12/barcamp-events/? [R=301,L]
RewriteCond %{QUERY_STRING} ^feed=atom&cat=1$
RewriteRule ^$ http://www.mellowmorning.com/category/symfony/feed/? [R=301,L]

Note that HTTP_HOST and QUERY_STRING are by not included in the conditions checked by RewriteRule. The rewrite rule only gets the part after the / and before the ?. That is why the combination of RewriteCond and RewriteRule is used.

To add the www. to the link:

RewriteCond %{HTTP_HOST} ^mellowmorning.com$ [NC]
RewriteRule ^(.*)$ http://www.mellowmorning.com/$1 [R=301,L]

Alternatively to remove it:

RewriteCond %{HTTP_HOST} ^www\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Dealing with trailing slashes:

RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1/ [R=301,L]

And here finally the total result:

It was great fun to learn more about this excellent feature. Be sure to check the mod_rewrite documentation, it is written very well.

<IfModule mod_rewrite.c>
RewriteEngine On
# Deal with three old posts
RewriteCond %{QUERY_STRING} ^p=11$
RewriteRule ^$ http://www.mellowmorning.com/2007/08/27/picture-resizing-on-steroids/? [R=301,L]
RewriteCond %{QUERY_STRING} ^p=3$
RewriteRule ^$ http://www.mellowmorning.com/2007/08/18/ten-reasons-why-symfony-rocks-part-1/? [R=301,L]
RewriteCond %{QUERY_STRING} ^p=4$
RewriteRule ^$ http://www.mellowmorning.com/2007/08/12/barcamp-events/? [R=301,L]
RewriteCond %{QUERY_STRING} ^feed=atom&cat=1$
RewriteRule ^$ http://www.mellowmorning.com/category/symfony/feed/? [R=301,L]
# If subdomain www exists, remove it first
#RewriteCond %{HTTP_HOST} ^www\.([^\.]+\.[^\.]+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# If subdomain does not exists, add it first
RewriteCond %{HTTP_HOST} ^mellowmorning.com$ [NC]
RewriteRule ^(.*)$ http://www.mellowmorning.com/$1 [R=301,L]
# If requested resource does not exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
# and does not end with a period followed by a filetype
RewriteCond %{REQUEST_URI} !..+$
# and does not end with a slash
RewriteCond %{REQUEST_URI} !/$
# then add a trailing slash and redirect
RewriteRule (.*) $1/ [R=301,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Apache & Web Development tschellenbach 05 Sep 2007 4 Comments