Blog

Custom Permalinks

200811011939.jpg

Custom Permalinks is a WordPress plugin that gives you ultimate control over your site structure.

Lay out your site the way you want it. Set the URL of any post, tag or category to anything you want. Old permalinks will redirect properly to the new address.

Download

Download Custom Permalinks for WordPress from the Custom Permalinks WordPress plugin page.

If you like Custom Permalinks, please consider buying one of my products.

Installation

  1. Unzip the package, and upload ‘custom-permalinks’ to the ‘/wp-content/plugins/’ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Edit any post, tag or category to set a custom permalink.

Configuration

  • Open or create a post, tag, or category.
  • Under ‘Custom Permalink’, type in a URL, not including the http://domain part of the address.
  • Save

Now, the post/tag/category will be accessible at the custom address.

Incoming visitors from old links will be redirected via a 301 redirect to the new address.

See Custom Permalinks in action right here! (See the address you’re currently at?)

Notes

Interacting with other plugins which modify the URL

If you notice that some plugins, such as Keyvan Minoukadeh’s Paged Comments plugin, are not operating correctly, then ensure that your custom permalinks have a trailing slash (or not, if your standard permalinks do not have trailing slashes).

The Paged Comments plugin, and possibly others, work by adding a path component to the URL to signify state (eg. /comment-page-1), then hiding that path component from WordPress.

If you have a custom permalink with a different trailing / configuration to your normal permalinks (i.e., your custom permalink has a trailing / when others don’t, or vice versa), you will notice that these plugins no longer work, because Custom Permalinks is correcting the URL, which overwrites the plugin’s changes.

If you notice this happening, make sure you have a trailing / on your permalink, or remove the trailing slash if your standard permalinks do not have a trailing /.

Hiding the custom_permalinks custom field

A user recently asked for this; I’m not going to include it in the plugin (some people, including me, want to see this field, because we set it manually sometimes), but I’m happy to make a plugin-let to make it happen.

Here it is: hide_custom_permalink_field.php.zip

Put it in your wp-content/plugins folder and turn it on in Plugins under WP admin.

FAQ

I just get a “404 error” message when I try to visit a custom permalink

Have you configured your default permalinks to be other than the default “?p=123″ style? If not, you probably haven’t got URL rewriting enabled. Either set your permalinks to one of the other options (or a custom layout), or add the following to your .htaccess file in your webroot, creating this file if necessary:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

History

Version 0.6.1: Fix bug causing incorrect link from “View Post”/”View Page” button in post/page editor

Version 0.6: Fix infinite redirect for permalinks ending in a / (critical fix), and moved post/page permalinks settings to top of edit form, replacing prior permalink display

Version 0.5.3: Fix for invalid URL redirect (eg. http://domain.comfolder/file.html instead of http://domain.com/folder/file.html) when using permalinks without a trailing slash (like …/%postname%.html)

Version 0.5.2: Bugfix for matching posts when there are multiple posts that match parts of the query

Version 0.5.1: Compatibility fix for WP 2.7′s tag/category pages

Version 0.5: Support for installations in subdirectories (i.e. not located at the webroot). This should make Custom Permalinks start working for many people.

Version 0.4.1: WP 2.7 compatability fixes; fix for bug encountered when publishing a draft, or reverting to draft status, and fix for placeholder permalink value for pages

Version 0.4: Added support for pages, and fixed a bug concerning post drafts.

Version 0.3: Largely rewritten to provide more robust handling of trailing slashes, proper support for trailing URL components (eg. paging)

Version 0.2: Added management page to display all custom permalinks, with an option to revert selected items

Version 0.1.1: Fixed problem with categories

Version 0.1: Initial release

Related posts

Tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

130 Comments

  1. William
    Posted June 7, 2010 at 6:49 pm | Permalink

    Hello…nice plugin. Unfortunately I can’t get it to work. When I create tag and then edit a page post, type in the custom permalink, and then try to visit the page the page doesn’t come up. The link is correct, but the page is not found.

    I have WordPress 2.9.2 and the latest version of the plugin.

    Any ideas?

    Thanks

    • Posted June 7, 2010 at 7:21 pm | Permalink

      Hi William – I’ve just added your answer to a new ‘FAQ’ section above. Does that address your problem?

  2. Posted June 9, 2010 at 10:40 pm | Permalink

    I’ve been trying to research this issue to customize my permalinks. I’m getting the same error message. I’ve looked up about the .htaccess edit, but I can’t get it to work. I followed a tutorial where it said to create a text file and save it as htaccess.txt and then include the code that you mentioned:

    RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

    Then following the tutorial, I uploaded this into my “www” folder and then renamed the file to .htaccess which makes it disappear. Then my entire site went down. I had to ask tech support to bring it back up. Is there another easier way to update or add the .htaccess file?

    • Posted June 10, 2010 at 7:51 pm | Permalink

      Hi David – Best ask your web host support for this one, or, in a bind, the WordPress support forums. It may depend on your web host’s setup.

  3. Posted June 10, 2010 at 6:29 pm | Permalink

    Great plug-in, thanks very much. Seems like something that should be included in WP options, so thanks for solving my problem! I’ve rated it 5 stars on the WordPress site and “works” with the 2.9.2 and 0.6 version combination. Again, thanks.

    Greg

  4. Tanner
    Posted June 11, 2010 at 9:26 am | Permalink

    For those having problems and getting a 404 error, make sure the .htaccess file as permissions of 666, so that it can be written to. This fixed the issue for me. Hope it helps :)

    wordpress 2.9.2 custom permalinks 0.6

  5. Posted June 11, 2010 at 7:51 pm | Permalink

    I’m a bit stumped. Maybe I did something wrong. When I create a page and create a custom link, for some reason its creating another page from the homepage where the slideshow images aren’t working…. what did I do? I created a sample problem page called Test Page. Here’s the link:

    http://davidchanportfolio.com/blog/testpage

    So the custom link works here! Woo! But what did I do wrong? Why is it displaying the homepage like that? I must’ve missed something…..

  6. Posted June 12, 2010 at 10:31 am | Permalink

    你的插件相当强大,感谢分享 ^_&

  7. Posted June 15, 2010 at 11:36 pm | Permalink

    Excellent plugin – thanks for releasing it! I was able to keep my internal page structure with sub-pages for easy menu generation, but define a more SEO-friendly URL structure for the site I am currently working on.

    5 stars from me – thanks again!

    • Posted June 16, 2010 at 11:58 am | Permalink

      Great to hear, Elliot – Glad to help =)

      Cheers!

  8. Derrick Tran
    Posted June 18, 2010 at 8:03 pm | Permalink

    This is a great plugin.. I just noticed something though. We just updated to WordPress 3.0 and there is a bug with the “View Page” button when editing a page inside the dashboard.

    It returns this when there isn’t a custom permalink defined “http://domainname.com/parent-page/%pagename%/”

    The error would be “%pagename%/”

    • Posted June 19, 2010 at 1:35 pm | Permalink

      Thanks for letting me know, Derrick! 0.6.1 should fix this

  9. Posted June 22, 2010 at 1:20 am | Permalink

    I just updated the custom permalinks plugin to version 0.6.1. My latest post is now giving a 404 error when I try to click on the permalink from the index as well as from category pages.

    You can see the latest post on my main page http://theviolent.net/ The permalink is defined as http://theviolent.net/ps-others/dandelion.

    If I try to remove the custom permalink by leaving the field blank, and have wordpress define the permalink, I still get the 404 error.

    • Posted June 22, 2010 at 10:38 am | Permalink

      Hi Christopher,

      Sorry to hear that! Hmm, all those links seem to be working for me (although it’s odd that both ps-others/dandelion and ps-others/electric-dandelion work).

      Does 0.6 work?

      • Posted June 22, 2010 at 2:23 pm | Permalink

        Yeah, it was a really strange thing. My first post was called Dandelion. And no matter what permalink I put in, I received a 404. I deleted the post and then added a new post with a different name call Electric Dandelion, and it worked. I couldn’t for the life of me find what was causing the 404 from the first post.

  10. Jeff
    Posted June 22, 2010 at 4:12 pm | Permalink

    I cannot figure out where to put the .htaccess file? I have serveral website running on my server. Do I put it in the /var/www/html/website1/ ? I put it there and it still does not work. I get the 404 error.

    • Posted June 22, 2010 at 8:55 pm | Permalink

      Hi Jeff,

      The .htaccess file goes in your webroot. If it’s not working, I’d contact your web host’s support.

  11. Posted June 22, 2010 at 4:24 pm | Permalink

    I am having a conflict with another plugin which needs to rewrite urls to work. I tried to explain the problem in a comment, but it kept saying it was spammy. So I opened a post on the word press forums explaining the problem.

    If you have any ideas on the work around, please let me know. http://wordpress.org/support/topic/413522?replies=1

    Thanks for your help.

  12. Posted June 22, 2010 at 8:46 pm | Permalink

    Hi Michael, Not sure if this was answered already, but does your plugin support adding file extensions (i.e. .php) ?

    ~ Matthew

  13. Posted June 22, 2010 at 8:48 pm | Permalink

    Also, the site I am trying to use this on: http://www.online-health-insurance.com/articles/2008/04/

    Is using a custom.conf file to handle server-side redirects, so there is no .htaccess, but the custom permalinks are working.

    On the link above, you can see two pages I am trying to use your custom permalink plugin on, but I get a 404 error.

    Thanks, Matthew

    • Posted June 22, 2010 at 10:55 pm | Permalink

      nevermind, our admin had a different rule in the custom.conf that was intercepting the file because of the .php extension.

  14. Posted June 26, 2010 at 12:15 am | Permalink

    Hello Michael,

    This is an excellent, but I do have one question. I don’t like typing the permalinks for the pages/posts, as I like the default permalinks and would like to keep it so wordpress does it automatically. Is there any way for me to disable this plugin only for posts/pages? I’m mainly using this for only categories.

    Thanks, Jordan.

    • Posted June 26, 2010 at 1:31 am | Permalink

      Hi Jordan,

      Unless there’s something going wrong with the installation, as long as you don’t specifically provide a custom permalink for a post/page/category/tag, the default will be used. Is there something not working properly?

      • Posted June 26, 2010 at 1:38 am | Permalink

        Great! Didn’t realize that! I’ve tried numerous custom permalink plugins and this is the only one that actually works and does what I need. Thanks for a great plugin! 5 stars!

      • Posted June 26, 2010 at 4:01 am | Permalink

        Actually from what I’ve seen in using the plugin, if a category has a custom permalink assigned and a post in that category does not, it will produce a 404 error for that post.

        • Posted June 26, 2010 at 1:01 pm | Permalink

          Cheers, Jordan =)

          Actually, this plugin isn’t designed to take the place of WP permalinks, for which you can define a pre-set structure. In Custom Permalinks, a category tag doesn’t affect anything else (like the posts that have that category).

          If you want the site organised by category, you just need to use the built-in permalink preferences to do so; set your permalink to %category%/%postname%/ for instance.

          If you’ve already got that structure set up, and you assign a custom permalink to the category, it’s actually not going to change the permalinks of the posts underneath the category – the way the WP permalinks system works, the %category% placeholder refers to the category’s slug, and not its physical URL.

          If there’s enough demand, I may be able to find a way around that limitation, but there hasn’t been so far =)

          • Posted June 26, 2010 at 4:59 pm | Permalink

            I appologize, I didn’t quite follow what you were saying. My wordpress permalink structure is defined as you said “%category%/%postname%” But I use your custom permalink to remove the child-category nesting from the url.

            For example I have a category called grunge. The wordpress permalink defines it as root/art/photoshop/grunge. I use the custom permalink to define it as root/grunge.

            If I forget to add a custom permalink definition on a new post in the grunge category, the post takes on the wordpress default permalink, but generates a 404 error. Any time I forget to define the custom permalink for any new post, it defaults to the wordpress structure, but always generates a 404 until I go back and define the custom permalink.

          • Posted June 26, 2010 at 6:00 pm | Permalink

            Ah yes; so this occurs because of the way WP’s permalinks are implemented, where %category% refers to the slug of the category, and not its physical URL (which Custom Permalinks can change).

            I may have a look at this one day, see if there’s any sensible way to work around it, but for now, I guess keep doing what you’re doing =)

          • Posted June 26, 2010 at 6:28 pm | Permalink

            It only happens when I am dumb and forget to define the custom permalink. But it was the reason I asked once about the possibility of post inheritance where the post inherits the custom permalink structure of the category.

            For example: all new grunge posts would by default have the custom permalink root/grunge/newpostname

  15. JR Oakes
    Posted July 3, 2010 at 9:37 pm | Permalink

    Any chance this plugin would make 404 requesetsredirect to index.html or home?

    • Posted July 21, 2010 at 1:49 pm | Permalink

      Nope, but you could probably do that by adding <?php header("Location: /"); ?> to 404.php in your template.

  16. Posted July 8, 2010 at 1:24 am | Permalink

    Another suggestion: ignore uppercase and lowercase.

  17. Posted July 21, 2010 at 12:11 pm | Permalink

    Hi Michael.

    Thanks for this nice plugin. I have some posts published under the category “cat1″ an the permalinks like this: /%category%/%postname%/. I edited the cat1 permalink to appear like “supercategory/”. So my question is: Is there a way to make the posts under cat1 to have a permalink like: supercategory/%postname%/ instead of cat1/%postname%/ automatically?

    Thanks for your support.

    • Posted July 21, 2010 at 1:50 pm | Permalink

      Cheers Hernan! I’m afraid not, at least not yet – you’ll need to set the permalinks manually. I may do this at a later stage, though.

  18. Posted July 28, 2010 at 9:06 pm | Permalink

    We have converted over a website from asp to WordPress and are using the custom permalinks plugin to keep google happy. After the migration we started seeing a massive amount of 404 errors on google wmt’s. Some of the links look like this: http://www.mesotheliomahelp.net/&gt;Mesothelioma, Asbestos Cancer, Mesothelioma</mesothelioma-doctors-AK.asp and obviously do not link back to correct pages. We have run link checkers as well as Xenu and cannot find out where google is getting these errors. I have to admit we are stumped. Do you have any clue where we might look?

    • Posted July 29, 2010 at 8:57 pm | Permalink

      No idea I’m afraid, JR

      • Posted July 29, 2010 at 9:36 pm | Permalink

        Michael,

        Thanks for looking. I submitted a modification to the sillybean html import tool for WP that integrates with your CP plugin. I have a copy if anyone is interested. It works great for importing a whole site of html(or other) and keepin the links the same. I think Steph ay Sillybean is going to integrate it into her next release. Thanks for the great tool.

        JR

  19. Cuyo
    Posted July 29, 2010 at 6:49 pm | Permalink

    Hi Michael. Great plug-in… I’d have it in my host without any problem, but now I need to use it in a web host wihtout mod_rewrite on. Is there any way? Thanks, for your time. Cuyo

    • Posted July 29, 2010 at 8:46 pm | Permalink

      I’m afraid not, Cuyo – it’s mod_rewrite only

      • Cuyo
        Posted July 30, 2010 at 10:06 am | Permalink

        thanks for your quick response. It is a pity that can not be used without mod-rewrite, but it is logical …. mmmmm … do you know any plug-in to do the same (custom url 100%) without mod-rewrite?

        • Posted July 30, 2010 at 1:55 pm | Permalink

          Actually, it just occurred to me that there’s something you could test – Try setting the permalinks as being prefixed by a “?” – like, “?my-custom-permalink”. It may actually work…

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Subscribe without commenting