views:

89

answers:

2

Hi! We just switched to our new website redesign.

We have a copy of the previous one in a folder "v1" and the new one is in "v2". I play with 2 .htaccess files. The file are organised as such:

root
 L .htaccess (1)
 L v1
 L v2
    L .htaccess (2)

.htaccess 1 does 2 things:

  • remove the www out of the URI
  • redirects all requests to v2/

The rules are:

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

RewriteCond %{REQUEST_URI} !^/v2/ [NC]
RewriteRule ^(.*)$ /v2/$1 [NC,L]

Now, I have specific URLs that are well indexed. For example: example.com/pixflow/

I would like to 301 redirect it to example.com/projects/pixflow1/ (which physically means example.com/v2/projects/pixflow1/)

To achieve this, I've put in .htaccess 1:

RewriteRule ^pixflow/$ http://%{HTTP_HOST}/projects/pixflow1/ [L,R=301]

But that does not work, it returns 404. What am I doing wrong?

A: 

it seems putting this in .htaccess (1) works:

RewriteRule ^pixflow/$ http://domain.com/projects/pixflow1/ [L,R=301]
pixeline
+1  A: 

You can just state the absolute URL path for the substitute:

RewriteRule ^pixflow/$ /projects/pixflow1/ [L,R=301]

But yours should work too.

Gumbo
excellent! makes the htaccess file lighter and more readable.
pixeline