1
votes

I've tried for ages to find a solution to this but to no avail.

In a nutshell...

I have a WordPress site within which I have a few pages that I want to change the URLs for. I don't want them to be custom post types if it can be avoided, I wish to use my theme's standard page templates without having to change or add any.

Can this be achieved simply using .htaccess? All my attempts have resulted in 404s so far. I've seen in the codex that you can do similar but not 100% sure how this works with pages instead of posts.

Note that I don't want a redirect, just to change the URL.

Example:

domain.com/page-reviews

I wish to be...

domain.com/page/reviews

The rule will always be the same, effectively anywhere that 'page-' appears, I need the dash to be replaced with a slash - 'page/'

Thanks to anyone who can help!

1
Have you tried changing the permalink options? - Howli
I've got the option set for /%postname%/ which I need to leave as it is so that other pages/posts aren't affected I believe? - davidsneal

1 Answers

0
votes

You can't do it through any .htaccess modification, if you are going to rewrite your slugs externally from Wordpress you will end up having 404 errors (or 500 or even a redirect loop, in the worst case scenario). Wordpress will look through its entire database searching for the matching requested path, which obviously would be inexistant.

If you want your pages to sit under a section, let's say /page/ you can easily create a Page with the slug page and then a child page with the slug reviews, so your final page will show the /page/reviews page, you need however to edit each page to amend the slugs where necessary.

If you are, however, using Posts then just use the Custom Permalinks plugin, it allows you to rewrite and add slashes into the full slug in the edit post screen, also in this case you need to go through all posts and change the slug pattern.

We've been using it flawlessly for about the last 2 years in a blog of a big corporate, however keep in mind the author is not maintaining it anymore so it might break at some point in the future and probably you might need to readapt it.