1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with 301 redirects please

Discussion in 'Off Topic' started by Mr Lucky, Dec 26, 2015.

  1. Mr Lucky

    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:

    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?
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Add an extra rule to exclude the empty path:

    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).
  3. Mr Lucky

    Mr Lucky Well-Known Member

    Many thanks Jake.

    In fact I that wasn't quite what I meant but useful for something else.
  4. Mr Lucky

    Mr Lucky Well-Known Member

    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


    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?

  5. Mr Lucky

    Mr Lucky Well-Known Member

    Not to worry got that one sorted now.

Share This Page