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
https://forums.phpfreaks.com/topic/87621-solved-htaccess-forward-redirect/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.