开发者

htaccess redirect only subdirectory requests (not requests for TLD)

I moved my blog from example.com to example.com/blog. I now have a splash page at example.com. I would like old blog post requests like example.com/2011/example-post to redirect to example.com/blog/2011/example-post; but requests to example.com to be al开发者_如何学Golowed with no redirect.


Try this:

RewriteEngine On
RewriteRule ^([0-9]{4}/.+)$ /blog/$1 [R=301,NC]

this will redirect all that have digits 4 digits (year) and something after slash so everything you have in example.com will work like regular page example.com/about.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜