.htacces - Move all messages in the root folder to a new category

Can anyone help me? I am in the last salon and am losing a lot of traffic. Any help would be greatly appreciated.

After a year, based on my permalink structure, all posts were at the root, so Google was chosen as:

snowmenu.com/postname

By changing my categories and permalink structure, I need posts that have been standing for a year to be redirected to Google:

snowmenu.com/ski-snowboard-winter-sports-news/postname

Is there a way to do this via .htaccess?

Thanks to everyone who can help me.

+2


source to share


3 answers


Just took a look at the website and I'm afraid that as far as I know this is not an easy way to do this type of forwarding with .htaccess.

This is because it is impossible to tell the link structure from a "normal link", for example, (eg http://www.snowmenu.com/ski-resorts/)

and what you want to redirect to (eg http://www.snowmenu.com/ski-snowboard-winter-sports-news/latest-ski-news/)

. If you redirect all requests, you end up with links like http://www.snowmenu.com/ski-snowboard-winter-sports-news/ski-resorts/

, which, if I'm right, are not desirable?

The long-term solution would be to create an htaccess redirect for EVERY URL.

The only other solution that comes to mind is to use PHP (or simular) to redirect within your 404 document.



EDIT
This will redirect ALL requests to the correct page. But as I said, I don't think this is what you want?

RewriteRule ^(?!ski-snowboard-winter-sports-news)(.*)$ /ski-snowboard-winter-sports-news/$1 [L,R=301] 

      

EDIT 2
After thinking, I think I came up with a viable option. This will check if the requested file exists if redirected to your new directory (theoretically: P).

RewriteCond %{DOCUMENT_ROOT}/ski-snowboard-winter-sports-news/$0 -f
RewriteRule ^(.*)$ /ski-snowboard-winter-sports-news/$1 [R=301,L]

      

0


source


You can use this plugin to avoid messy .htaccess file interactions: http://wordpress.org/extend/plugins/redirection/



It has a nice interface for setting up redirect rules.

0


source


The plugin mentioned by @Wordpress Hardcore works the best.

0


source







All Articles