Vebut Posted January 24, 2008 Share Posted January 24, 2008 Hi! I've recently moved my blog to a subfolder/subdomain on my server. There for I wanted to forward or redirect my visitors coming from search engines looing for specific articles to the new subdomain. E.g.: vebut.se/2008/01/22/article-name/ New: blog.vebut.se/2008/01/22/article-name/ This is my solution: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^www.vebut.se/2008/$ [NC] RewriteRule ^(.*)$ http://blog.vebut.se/$1 [L,R=301] RewriteCond %{REQUEST_URI} !^vebut.se/2008/$ [NC] RewriteRule ^(.*)$ http://blog.vebut.se/$1 [L,R=301] This might not be the most optimized code and I'm sure there are better solutions. The articles listed on search engines are all from 2008, so the links that should be redirected is vebut.se/2008/ (+ following query string) and this url should be forwared / redirected to blog.vebut.se/2008/ (+following query string). And my code seems to do the work just fine, the problem is that my root (vebut.se) and other subdomains are redirected to blog.vebut.se. I'm no expert with .htaccess and would be very greatful if someone could help me out. All I want is that vebut.se/2008/ (+ following query string) should redirect to blog.vebut.se/2008/ (+following query string). Thanks! Daniel Lindén. Quote Link to comment https://forums.phpfreaks.com/topic/87621-solved-htaccess-forward-redirect/ Share on other sites More sharing options...
Vebut Posted January 24, 2008 Author Share Posted January 24, 2008 Solution: RewriteEngine On RewriteBase / RewriteRule ^2008/(.*)?$ http://blog.vebut.se/2008/$1 [r=301] Quote Link to comment https://forums.phpfreaks.com/topic/87621-solved-htaccess-forward-redirect/#findComment-448385 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.