Help with 301 redirects please

Mr Lucky

Well-known member
I want to redirect from one URL another (inside a subdirectory), keeping the file system the same except for the home page which redirects to the new homepage

So for example

oldURL/oldpage1 > newURL/folder/oldpage1
oldURL/oldpage2 > newURL/folder/oldpage2
oldURL/oldpage3 > newURL/folder/oldpage3
oldURL/ > newURL/

The first bit seems easy with htaccess:

Code:
RewriteEngine on
RewriteRule ^(.*)$ http://newURL/folder/$1 [R=301,L]

But also redirects the old homepage into the folder instead of to the root.

Can anyone help please?
 
Add an extra rule to exclude the empty path:

Code:
RewriteEngine on
RewriteRule ^$ - [S=1]
RewriteRule ^(.*)$ http://newURL/folder/$1 [R=301,L]

That extra rule matches the empty path (^$), does nothing (-), and then skips the next rule (S=1).
 
I now have another one if somebody could please help (e.g. @Jake Bunce )

I want to redirect all the page of a site (except the home page) into a folder on the same site,


BUT I want the home page (root URL) to direct to a new URL

e.g.


originalURL/page1 > originalURL/folder/page1
originalURL/page2 > originalURL/folder/page2
originalURL/page3 > originalURL/folder/page3

originalURL home page > newURL home page


Is this possible and if so how would I do it please?


Thanks
 
Top Bottom