开发者

.htacces - moving all posts in root to a new category

开发者 https://www.devze.com 2022-12-26 04:15 出处:网络
Could anyone please help me? I am at the last chance saloon and losing a lot of traffic. Any help would be greatfully received.

Could anyone please help me? I am at the last chance saloon and losing a lot of traffic. Any help would be greatfully received.

After a year based on my permalink structure, all posts were in the root so have been picked up by Google as:

snowmenu.com/postname

Since changing my categories and permalink structure, I need the years worth of posts on Google to be redirected to:

snowmenu.com/ski-snowboard-winter-sports开发者_StackOverflow-news/postname

Is there a way to make this happen via .htaccess?

Thank you very much to anyone who's able to help me.


Just had a look at the website and I am afraid from my knowledge their is no easy way to do this type of forwarding with .htaccess.

This is because there is no way to tell the difference in link structure from a "normal link" like (eg http://www.snowmenu.com/ski-resorts/) and what you want to be redirected to (eg http://www.snowmenu.com/ski-snowboard-winter-sports-news/latest-ski-news/). If you redirect all requests you will end up having links like http://www.snowmenu.com/ski-snowboard-winter-sports-news/ski-resorts/ which if I am right is not desirable?

The long solution would be to create a htaccess redirect for EVERY URL.

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

EDIT
This will redirect ALL requests to the page you want. But as I said before I dont think this is what you want?

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

EDIT 2
Having given it some thought I think I have have come up with a viable option. This will check to see if the requested file exists, if so it will redirect to your new directory (in theory :P).

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


You can use this plugin to avoid messing with .htaccess file directly: http://wordpress.org/extend/plugins/redirection/

It has a nice interface for you to configure the redirection rules.


The plugin mentioned by @Wordpress Hardcore works best.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号