Jump to content

[SOLVED] .htaccess forward / redirect.


Vebut

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.