Geronimo89.dk

A blog about me, my doings and everything I think deserves attention.

Making exceptions for WordPress URL rewriting

If you, as a bunch of other people out there, also are running a WordPress powered website, you may also want to use it for something else. To do that, you have to access data around WordPress rewriting engine. The rewriting is responsible for showing urls instead of urls like:

http://jmh-visual.com/?p=32

you get:

http://jmh-visual.com/2011/03/colourful-night-in-kolding/

which is great! They are a lot more understandable for humans. Problematic is a case when you just want to put a a file, another web-project, or even just demonstrate something for a tutorial you wrote. WordPress will capture, what you write behind your domain name and try to assign it to content in the system. To change that, we just need to change the .htaccess file in the root folder of your webspace. Connect to your webspace with an ftp client like Cyberduck and open .htaccess (If you don’t see that, try enabling hidden files).
You’ll probably see something like this:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

So let’s say we want to make the folder helloworld in the root folder accessable to people, without WordPress trying to find a page or post with that name.

# BEGIN WordPress
RewriteEngine On

RewriteBase /

RewriteRule ^helloworld($|/) - [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Give me the first comment

Leave a Reply