I have build a D8 website on domain www.example.com/abc and now wants to copy this site to www.example.com/xyz

Hosting is same

What I did is: 1) copied all files from abc to xyz. 2) Exported Database from abc and imported it to xyz. 3) Assigned new Database name, Username and Password to xyz in settings.php.

When I go to www.example.com/xyz Homepage looks perfect but when I go to inner pages it takes me back to domain www.example.com/abc.

How should I update the URLs?


Additionally to the suggestions of @Anson W Han, you will have to clear all your database stored routing caches. The easiest way to do this is running drush cr on the console from within your Drupal installation's root folder, if you have drush installed.

You can also run the database update script at yourdomain/xyz/update.php, which will flush the caches as well.

Third way is to logging in to your back-end and navigating to "Administration / Configuration Development / Performance" where you can clear the caches using the admin UI.

  • HI Mario, Running mydomain/update.php solved the issue! Thank you and Thank you all for the responses! I appreciate it. – mazhar khan Dec 18 '17 at 9:36
  • One last issue. One of the Pages have a list of articles in example/xyz site so when I click on that it takes back to the previous website. How can i update those? Manually or is there an easiest way? Thanks – mazhar khan Dec 19 '17 at 13:33
  • That depends on how the list was created. If the URLs are hard-coded, you will of course have to re-edit the URLs. If it is a view, you will have to check how this view builds its URLs. – Mario Steinitz Dec 19 '17 at 13:36
  • Thank you, for the reply! How can I share the link here if I have to show you want exactly I am looking for? – mazhar khan Dec 19 '17 at 14:01
  • I won't do support here. So no need to show me any links. ;) - If you find your specific problem is worth a new question, feel free to ask the community. I just fear it's connected to a bad implementation of either a custom module, view or hard-coded content. You should investigate this first, as it is very likely you won't get a response if you can't provide according details. – Mario Steinitz Dec 19 '17 at 14:10
  • More than likely, you have a redirect base directive in your .htaccess. This is used when serving your Drupal site out of a subfolder of your webhosting provider's webroot. You should check your .htaccess file for the directive RewriteBase /abc and replace with RewriteBase /xyz

  • If that still doesn't work, check the vhost entry of your webserver for the same directive.

  • Otherwise, if the site still redirects to "/abc", then you may have a $base_url defined in settings.php causing the redirect.

  • Hi Anson, thank you for the reply. I wanted to ask. I dont have .htaccess file in my main directory. example.com/xyz . So i have to create one and mention rewrite base? Thanks – mazhar khan Dec 20 '17 at 14:45
  • The .htaccess file should be in the root of your Drupal directory. Since its a hidden file, you might need to make sure you are viewing all files including hidden ones. If it's missing completely, only the homepage would load, no secondary pages including Admin section would work. Once you've confirmed it is in place, add the rewrite base directive and test again. – Anson W Han Dec 20 '17 at 14:51
  • I have an option in my Cpanel to view hidden files. It's not there. I checked. Shal I create one? Thank You – mazhar khan Dec 20 '17 at 15:06
  • Recommend you copyright the .htaccess included in a vanilla Drupal download to that file location – Anson W Han Dec 20 '17 at 15:10
  • you mean .htaccess file from fresh Drupal download? – mazhar khan Dec 20 '17 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.