Clean URL’s with WordPress

This tutorial will show you how to setup WordPress to use clean URL’s. Using clean URL’s is one of the first step in Search Engine Optimization (SEO). Besides that, they just look better.

The default WordPress URL structure is: What does p=123 even mean? Well, I would guess that it is the post id, but what does your reader see? A URL like this will be much better: be much better. It will have some meaning to your readers, and more importantly, search engines. The title is one of the most important things a search engine will look at. The better your site places on the SERPs (search engine results page), the more traffic you will drive to your site. Of course this is only one step in SEO, but is a good start.

There is one thing to keep in mind before you change your permalink structure. You will lose inbound links from other sites and search engines. If you have a large amount of traffic from direct addresses or bookmarks, you will not have to worry about this. If you are just starting out (as we are here at, I would recommend going with clean URL’s from the start. It is really simple to make a custom permalink structure for WordPress.

First, if your .htaccess file is writeable, WordPress is supposed to update it automatically. If not it will give you the code to cut and paste into your .htaccess file. I have had problems letting WordPress edit the .htaccess file in the past (it never seems to update it), so I will edit it manually.

Log on to your WordPress account as the administrator and click on Options and then Permalinks. You should see a page similar to the one below.
Clean URL’s with WordPress

As you can see, the default settings are select. We want to enable custom URL’s so click the option button next to “Custom, specify below”.
Clean URL’s with WordPress

Now we need to define the URL’s. There are many variable that you can use, but I will choose to use the category and postname variables. If you would like to use something else (day, month, year, posted, subcategory, etc.) you may want to see the custom permalinks page on the Official WordPress site. In the “Custom Structure” box, enter the following.
Clean URL’s with WordPress

Now scroll to the bottom and click the “Update Permalink Structure” button.
Clean URL’s with WordPress

Now, if you have a writeable .htaccess file, you can ftp to your site and check to see if .htaccess file was edited. If your .htaccess is not writeable, or WordPress didn’t update it, you will need to enter the following code in the file and upload it to your site.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

This will tell the server that when it see to rewrite it to , but the user will see the clean URL.

To test it, make a new post or use an existing one. Click the link from your homepage to get to the permalink and look at the URL in the web browser. You should see the clean URL and the page should be displayed properly.
Clean URL’s with WordPress

Here is our ugly default URL versus the clean URL for the same post.
Clean URL’s with WordPress

Clean URL’s with WordPress

This is an easy way to optimize your site for search engines and be easier on your readers eyes. If you have any questions, just leave a comment, I will answer as quickly as possible.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join the TeamTutorials mailing list and get the latest tips, tricks, and special discounts for members only.

Thanks! Please click the link in the email we just sent you to confirm.

  • Great tip, thanks 🙂 I’m going to make sure I set this on all my blogs from now on.

  • Hello, I’m using Georgian language (UTF-8) and it has errors with encoding URL-s. can you help me?

  • Deborah

    This makes sense to me, except what happens if I have named pages, which aren’t necessarily categories?

    I’m new to blogs, just installed WordPress this afternoon, but want to have an “About” and “Contact” pages which are found through the links and

    How does your rewrite method affect how those pages are referenced?

  • If a file or folder exists, it is display. Noticed the REQUEST_FILENAME param. There are two of them in the rewrite statement. One !-f for file and one !-d for directory. This tells the web sever that if a file or directory exists, skip the rewrite rule.

  • By the way. We have been using this technique on the site for awhile now. We haven’t really had any problems with it. Except (if you guy’s noticed) we used an apostrophe in the title for this post. As you can see in th URL it doesn’t like the apostrophe and it makes the URL look messy. It is kind of funny that the only page on this site with a bad URL is the one about cleaning your URL’s.

  • Deborah

    Thanks John for the quick response! I’m moving along with my WordPress site. Sure helps to have sites like yours with good advice to answer my questions.

  • it seems that apostrophes in permalink is a wordpress bug, maybe the list of special characters that get sanitized should be updated, look:

  • André Felipe

    What if an article has two categories? How will be the URL of this article?

  • Benji Franklin

    Question: How do I change .htaccess and configuration to add the www at the beginning of the URL? It has been eliminated somehow during set-up and now I see I have lost my old page rank which was at the www address. Arghhhh …. In addition to changing the .htaccess and wordpress config would I need to change anything in my template .. think I have some links hardcoded in there without the www which I might have to redo or would they be redirected so long as I change .htaccess?

    Anyway, great site.

    Any help would be great appreciated.

  • @Benji Franklin … I think you have to setup this from your domain registrar. I can tell you for sure it’s not htaccess.

  • yes you can set the prefer domain to or This is not a function of the registrar you can do this in .htaccess.

  • In addition to changing the .htaccess and wordpress config would I need to change anything in my template .. think I have some links hardcoded in there without the www which I might have to redo or would they be redirected so long as I change .htaccess?

  • darkdragon312

    your information was very helpful. i understand everything until it reaches the step about .htaccess. could you elaberate on the steps after that, please reply to my e-mail.

    A response would be heavily appreciated

  • great tips.i will try later on my new built wp websites.thanks!

  • Great blog you got here…keep up the good work.

  • Navin

    Hi Pal,

    I implemented the same way as written in the article above for clean URL. On hovering on the post I am getting clean URL. I tried opening the post, it is showing –

    Oops! This page appears to be missing.
    HTTP 404 – File not found.

    Please let me know how to rectify this problem.

  • This information is very helpful for my needs. Thank you very much

  • I’m using Drupal and it handles this function out of the box extremely well… HOWEVER. It’s like driving a ferrarri in bumper to bumper traffic and I need to scale back to wordpress in order to save myself from a huge insurance claim.

    I’ll give this a try as soon as I get a second. Thank you!

  • Hank

    4 0 3 error!

    difficult to get the site back to working.

  • JohnS

    Please help 🙁
    I want to transform this:

    What must i write in .htaccess?!?

    I’ve tried a million things and nothing works… Please help, i must launch my web-site soon and i’m a noob lol, but no one must know that 🙂
    Thank you.

  • So I attempted subscribing to your RSS .xml, and it kicked back a “404” error… Can you tell me if it’s just me or the site?

  • I just MicroVolts. Here’s a shooter game oriented around toy soldiers at a secret feud against each other, and when you pick in this war you will be tactile to use some first class cheats, because days. You can try these excellent MicroVolts Cheats simply, just goto and get the best hacks available.

  • thanks for the great subject matter, i just stunbled on your site? well done superb information

  • Thanks for the tip/link that you posted on my own website. I didn’t succeed because I couldn’t find the htaccess file you talk about?

  • Many Many Thanks. My site is in Drupal 7.9, But I would like to change into WP. I was searching how to create clean urls and found your post. Just tried, and wow, done it.

    Sir, Can you help me please? I would like to know any plugin available for migrating/converting my drupal 7.9 site into WP. Basic pace, Book page, Gallery, Youtube videos etc are the contents. Pls help if u can.