Valentin Montmirail Valentin Montmirail - 4 months ago 23
MySQL Question

Changing URL in Wordpress : Absolute links

I'm currently changing the URL of a Wordpress website, and I've got problems with it...

First of all, let's write versions of what I'm using


  • Wordpress: 4.5.3

  • MySQL: 5.5

  • PHP: 5.6



The website is hosted at
www.xxx.com/blog/
and when I access this URL, everything is working as expected, but I want to change this URL to
www.yyy.com/


So I paid a domain name
www.yyy.com/
(with http://godaddy.com) and I made a forward with masking from
yyy.com
to
xxx.com/blog


So now, when I access
www.yyy.com/
, I access the home page of the website, and the URL is
www.yyy.com
but here start to be the problem...

Only the home page is working, all the links to the posts are dead...
So I made a search and replace in the database, and I change all the link
www.xxx.com/blog/2016/zzz
to
www.yyy.com/2016/zzz
and when I access them directly by URL it's working, but when I access them by clicking on the website, the link is
www.xxx.com/blog/2016/zzz
and the URL is staying
www.yyy.com
(not keeping trace of
/2016/zzz
...)

So I then find out that there are 2 variables in the database:


  • siteurl
    =
    www.xxx.com/blog/

  • home
    =
    www.xxx.com/blog/



and if I change just one of these 2 variables to
www.yyy.com/
the website dies, I get a blank page and nothing is not working anymore...

So currently, I've got:


  • A domain name
    yyy.com
    which make a forward with masking to
    xxx.com/blog/

  • All the link the posts are
    www.yyy.com/2016/zzz
    in the database.

  • Access the URL
    www.yyy.com/2016/zzz
    directly is working.

  • Access the URL
    www.yyy.com/
    directly is working.

  • siteurl
    =
    www.xxx.com/blog/

  • home
    =
    www.xxx.com/blog/



Problems that need to be fixed:


  • Links on the website are still
    www.xxx.com/blog/2016/zzz

  • siteurl
    and
    home
    are the old URL but if I change them, I've got a blank page.



I hope anyone had already this issue and will be able to help me :)




EDIT

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


Best Regards,

Answer

In your .htaccess file change the rewritebase to / instead of /blog/ when you are using www.yyy.com, then change siteurl and home to www.yyy.com