views:

371

answers:

3

I am using wordpress and use custom permalink structure: /%category%/%postname%/

My problem is that a decent number of people link to the site without including the trailing slash in the URL, so users get a 404 page.

I'm using the default .htaccess file that comes with wordpress because no solution I've tried has worked. I've tried using the Redirection plugin, with no success.

I'd gladly link to the site, but I don't want it to be construed as self-promotion. If you ask, I'll provide a link.

Could anyone help me find a plugin or provide some .htaccess entries to help resolve this?

Thanks very much!

+2  A: 

Use:

/%category%/%postname%(/?)

in your .htaccess file.

The question mark denotes an optional character sequence.

Dominic Rodger
No need for the parentheses, unless you're planning on passing whether or not there's a / as a GET variable.
ceejayoz
True - IMHO it makes it look a bit clearer though.
Dominic Rodger
I'm a bit confused about how to use that in .htaccess. /%category%/%postname%/ is being used under the settings tab of the wordpress admin interface, not in .htaccess. Is it possible to use regex within the permalink settings?
Eric Wendelin
+2  A: 

A very good reference for all things .htaccess is PerishablePress.com

http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/

Jordan Ogren
+1  A: 
RewriteRule ^(([^\/]+\/)*[^\/\.]+)$ $1/
eyelidlessness
And of course "RewriteEngine On"
Chris Dolan
I would imagine it's already enabled if the permalinks specified in the question work.
eyelidlessness