Rewrite or Redirect old website domain to new domain with new url structure

Home Forums BulletProof Security Free Rewrite or Redirect old website domain to new domain with new url structure

Viewing 15 posts - 16 through 30 (of 36 total)
  • Author
    Posts
  • #20256
    AITpro Admin
    Keymaster

    I’ll try a couple of things on a test site and see if I can get that to work.  Personally I know there is a much better approach to what you are trying to accomplish, but I would need to know the entire scenario.  Will post back here shortly.

    #20258
    AITpro Admin
    Keymaster

    Actually this code does redirect correctly as long as it is above the WordPress Rewrite code, which will rewrite the home page / index.php. On some hosts you need to include the folder name where the site is installed in order for the redirect to work correctly. See the example below.

    RedirectMatch 301 ^/$ http://www.example.com/

    Example:
    folder structure: /siteA/

    RedirectMatch 301 ^/siteA/$ http://www.example.com/
    #20261
    Goodvalley
    Participant

    Totally new to the .htaccess rules here, please have some patience with me… What do you mean by “…as long as it is above the WordPress Rewrite code…”? I mean, I tried the same code you put above before asking here, with/without the final slash, with/without $1, etc… There must be something that blocks the completion of the page request, I’m sure the “redirectmatch 301…” code is right. Regarding the structure, my two sites are really simple, just some pages and posts. No files to download, no membership or private areas, nothing really special.

    #20263
    AITpro Admin
    Keymaster

    The standard WordPress rewrite loop start code in  your root htaccess file looks like this below.  You can add redirect code in the very top/first BPS Custom Code text box where php/php.ini handler and cache code goes.

    # WP REWRITE LOOP START
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    Take a look at this forum topic to get an understanding of htaccess file/hosting account hierarchy, structure, relationship and how things affect each other:  http://forum.ait-pro.com/forums/topic/htaccess-files-for-multiple-website-domains/

    What could be happening is you have a parent htaccess file that is affecting other child htaccess files.

    #20267
    Goodvalley
    Participant

    That didn’t work either. I wrote RedirectMatch 301 ^/$ http://www.skireviewer.com/ in the first box of the Custom Code of the http://www.skimatters.com .htaccess file. Then I created the two files in the Secure Mode, activated the Root Folder BulletProof Mode and the wp-admin Folder BulletProof Mode, then the Master htaccess BulletProof Mode and BPS Backup
    BulletProof Mode. So everything should be fine. The result is the same. My new site cannot be reached.

    In fact, before asking in the forum I read the text from the link you just provided, but it didn’t seem to apply to my particular case just because it seems a very simple one. I don’t have any other redirect code in my .htaccess files nor anything special, just a root domain and a sub-directory sub-site. But this one has nothing, I didn’t touch anything.

    Is there any way you could see what I have exactly? I can email you a user profile and pass if necessary.

    #20269
    AITpro Admin
    Keymaster

    Manually edit your root htaccess file and only use/add this code below (add your actual domain name) in your root htaccess file without any other code.  Does your home page redirect correctly to the new site?  If not, then either there is a parent htaccess file that is applying its rules to this site or maybe you have a DNS setting somewhere in your host control panel that is causing the problem?  We are not allowed to login to BPS free folks sites sorry.

    RedirectMatch 301 ^/(.*)$ http://www.new-site.com/$1
    #20274
    Goodvalley
    Participant

    Obviously, with the (.*) thing added, it tries to go to the new site and it doesn’t even allow me to enter the WP back-end, because everything gets redirected. The problem is that the browser seems to be unable to make the request to the new page. At least that’s what it says. It wants to go there, but something stops it (maybe in the new site? what would be that?)

    Thinking twice…

    Ok, I’ve got several domains in the same hosting, which is BlueHost. My old site is the first site I had in this hosting (so it is also the actual main site). Then the other domains (such as my new site http://www.skireviewer.com) are like “secondary” sites in the same hosting. Every domain has its own WordPress Multisite installation on it, but the actual hosting structure could have something to do with all this problem. Does this give you any idea?

    #20275
    Goodvalley
    Participant

    Ok, theoretically each domain is compartmentalized, so they all have their own .htaccess files, but there has to be something that interferes. That’s the only explanation I can find.

    In any case, I installed BPS in both domains WP Multisite installations and didn’t add or touch anything. So the .htaccess files are “standard”, with the security modes normally activated.

    #20276
    AITpro Admin
    Keymaster

    So does the redirect work or not.  Typically when you are redirecting an old site to a new site you would no longer want or need to access that site.  It is possible to still allow logins to the site, but you would have to use code such as this:  http://forum.ait-pro.com/forums/topic/domain-masking-error/

    It is very possible that it has to do with the htaccess files and hosting account hierarchy, structure, relationship and how things affect each other.  Did you look at this link I posted above?  http://forum.ait-pro.com/forums/topic/htaccess-files-for-multiple-website-domains/  If you would like for me to provide any kind of clue I would need to know the structure of sites under your hosting account and where htaccess files are in each folder.  You can use the link above as a guide to post the same type of information about your structure:  ie folder names and folders with htaccess files in them.

    Ok, theoretically each domain is compartmentalized, so they all have their own .htaccess files, but there has to be something that interferes. That’s the only explanation I can find.

    That is pretty close, but if you look at the link posted above then there is a parent / child relationship with htaccess files. The parent htaccess file will apply its rules to all child htaccess files, UNLESS you specifically add code in the parent htaccess file to tell it not to do that.

    #20281
    Goodvalley
    Participant

    My old-domain (www.skimatters.com) is the root domain in the hosting’s File Manager hierarchy. It has its own .htaccess file with the standard BPS installation. Nothing else added to it.

    My new-domain (www.skireviewer.com) is a folder in the hosting’s File Manager’s hierarchy. It also has its own .htaccess file with a standard BPS installation.

    Yes, I’ve read the link. So the “child” domain seems to need some tweaking for the redirection to succeed, or maybe some rule changing, but I don’t know how to do it.

    #20283
    AITpro Admin
    Keymaster

    I tested the redirect code that you posted and it worked fine for me so I am not sure why it is not working for you.  The new site would probably not be blocking the redirect in any way unless you had added some specific code to do that.

    #20286
    Goodvalley
    Participant

    Yes, it should work. I will look more into it and tell you if I find something, it may be useful for others.

    Thanks very much,
    Carles Goodvalley

    #20344
    Goodvalley
    Participant

    Hi, as promised I’ll post the solution I came across with, as it may be useful to others, specially BlueHost clients:

    My domains are all in one hosting pack in BlueHost, so everyone can find a good insight by reading this good post in the forum: http://forum.ait-pro.com/forums/topic/htaccess-files-for-multiple-website-domains/

    Now, I have a Main Domain and the others are Secondary Domains. So theoretically, one has to go to the Redirect tool in BlueHost CPanel. BUT it doesn’t seem to end there. The tool works fine, but you must check if the code added to your .htaccess file is exactly what you need. In my case, I had to add a ‘?’ to a certain position to make it work properly.

    I would recommend also to make a copy of the code added to your .htaccess file. For example, if you use BPS, chances are that you erase all redirections recorded in the BlueHost CPanel with the Redirection tool. I think it’s much better to backup the code, add it manually in the correct textbox in the BPS Code Editor and save the settings, then delete the redirections made by the Redirection tool in the CPanel. Since you will have it permanently added to your .htaccess file, it will remain protected.

    #22677
    jenni101
    Participant

    Hi,

    I’m researching for the best way to redirect old/unused pages to a newer version with a site revamp. I’ve read that it’s quicker for page load times to do the redirects at server level, by which I assume they mean the redirection tool in cPanel (?). Can you confirm if this is OK to do it this way, as Charles (above) says that BPS overwrites these changes. I had assumed that if I was to turn off the file quarantine part, do my edits via cPanel, then do my file backups again in BPS and then turn back on Autorestore/Quarantine function it would then save the edits for redirection done in cPanel? Or is that all exactly the same as doing the redirects in my .htaccess file via Custom code in BPS anyway??? Appreciate your thoughts.

    #22678
    AITpro Admin
    Keymaster

    if you use BPS, chances are that you erase all redirections recorded in the BlueHost CPanel with the Redirection tool.

    The statement above is backwards.  The cPanel Redirection Tool looks at the root htaccess file code and then tries to calculate what to do/create itself and then makes those changes to itself in the cPanel Redirection tool settings.  So the cPanel Redirection tool is changing/modifying/deleting/erasing the redirections in the cPanel Redirection tool settings based on what it thinks it sees in the root htaccess file.  In the past there have been several cPanel tools and utilities that malfunctioned similarly to the cPanel Redirection tool.  I believe that the newest most current version of cPanel has fixed all of their cPanel tools and utilities so that they are no longer malfunctioning like this anymore.

    I recommend adding htaccess redirect code in BPS Custom Code, which is what I do for all of the AITpro.com websites including this site which has around 500 lines of redirect code/rules.  I guess if you have 50,000 to 100,000 redirects to do then it would probably be better to add them at the cPanel level otherwise anything less than 50,000 lines of htaccess redirect code can be created in your root htaccess file and there would be absolutely no difference in page load speeds.

Viewing 15 posts - 16 through 30 (of 36 total)
  • You must be logged in to reply to this topic.