Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

htaccess more than 1 rule

2:05 pm on Sep 6, 2012 (gmt 0)

New User

5+ Year Member

joined:Feb 23, 2012
posts: 17
votes: 0

Hi. Ive never understood how to write multiple rules in htaccess. Can someone help me please. Ive read all the threads and I just get lost when being explained how it all works.

My Current htaccess looks like this

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

# END WordPress

I need to add 1 rue to this. I am renaming my wordpress category base. The example I have is

RewriteEngine on
RewriteBase /
RewriteRule ^old_dir/(.*) http://www.example.com/new_dir/$1 [R=301,L]

Now my structure looks like this currently


I want it to be like this


Any help would be greatly appreciiates

[edited by: incrediBILL at 7:10 pm (utc) on Sep 6, 2012]
[edit reason] fixed code formatting [/edit]

2:52 pm on Sept 6, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
votes: 0

Make sure you have the RewriteEngine and Options directives just once each and listed at the top.

You can have as many rules as you like.

You need to put rules that affect a small number of URLs first, so they get processed first instead of more generalised rules. The non-www/www rule is usually the last rule of the redirects.

After the redirects, add your rewrites. This should also be ordered from most specific to most general.

Use RewriteRule for your redirects and your rewrites. Don't use Redirect or Redirectmatch.

Each RewriteRule rule can have one or more RewriteCond conditions that precede it.

A RewriteCond condition applies only to the next rule that follows it. The condition is evaluated AFTER the left side of the rule has been evaluated.

Add a blank line after each RewriteRule so you can see what is going on.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members