Eric Wendelin
Eric Wendelin

Reputation: 44369

How can I fix my .htaccess to resolve URLs that don't end in slashes

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!

Upvotes: 2

Views: 2080

Answers (3)

eyelidlessness
eyelidlessness

Reputation: 63529

RewriteRule ^(([^\/]+\/)*[^\/\.]+)$ $1/

Upvotes: 2

Jordan Ogren
Jordan Ogren

Reputation: 106

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

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

Upvotes: 3

Dominic Rodger
Dominic Rodger

Reputation: 99811

Use:

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

in your .htaccess file.

The question mark denotes an optional character sequence.

Upvotes: 2

Related Questions