Changing moodle site address
Several people have had success dumping a copy of the database in a text file, using their favorite editor (beware this could be a really big file) to search and replace, and then restore the modified dump back into the database.
Of course, you need to be sure noone is using Moodle while you do all the search, replace & restore. Otherwise you'll loose all the new content.
I'd do it in a test server first (even several times) to get a grip on it before even trying on the production server.
If you dont have time to explain, just lead me to somewhere i can get clear info about the issue.
thank you lots!
You edit that file and then restore (using mysql command line client, for example) your modified database back.
Simple yet effective.
I am using moodle 2.2 on arvixe hosting company with cpanel
I bought a new domain name and so I am using the same name server.
do I have to follow the below bold directions even if I am using the new URL on the same hosting company and same server?
my question comes from confusion regarding the following section of docs.moodle:
Change your Moodle URL. If you have a new URL, you'll need to change this in the Moodle database to the new server. This is needed as links to pictures, files, etc are stored as absolute links and will reference the old $CFG->wwwroot value. So when loading a mysql backup dump of the Moodle server into mysql on another server the absolute referenced links will be broken. There are two methods of doing this:
(a) The first method changes the Moodle URL using the Moodle script replace.php while your site is currently running just before you backup the Moodle database. Point your browser to http://yourserver.com/admin/replace.php
Enter the url for your old server (http://oldserver.com/) and new server (http://newserver.com/) and it will fix the mysql tables.
Do I need to do this even if I am on the same server? Because I am chaning url from
If so how?
I get the following message: "Incorrect access detected, this server may be accessed only through "http://myServerHostName" address, sorry.
Please notify server administrator.
This page should automatically redirect. If nothing is happening please use the continue link below.
I use PHPMyAdmin to edit the database directly calling a file with a number of SQL update commands of the form:
I have attached a file with the full set I use. This may not adjust all the tables you have references in and I know it does not address the problem with links or images in labels.
WARNING try this on a test server first and make a backup of your database in case.
thnx for the reply. BUT, I know the office here is very very picky and they want to do this without breaking ANY link, whether the link was for the smallest picture or any other resource .
Do you think Mr. Inaki's solution better satisfies the needs of my department?
I have used Iñaki's solution but my database is very large and the mysql dump was therefore a large file which took a long while to process in my text editor before reading back in.
My sql script runs in less than a second in place and as I use this at least once a day when I restore a backup of my live site into my development site this is a great advantage.
If you do find any broken links they can always be edited manually which is what I do with the link in a label which I have not managed to sort out any other way!
How can you manage editingi manually if you have around 300 courses? You will first have to identify and search for any broken link in all these courses and then fix manually?
On a one off basis you are probably better off using Iñaki's solution as if it takes a long time then this will only be the once.
I think my script gets every occurrence except labels and I was only suggesting manual editing for any which were missed as they were reported to you.
For those Unix/Linux admins out there, using 'sed' to process the database dump makes the search & replace operation blazingly fast
If you've got a sed that's option compatible with GNU sed, you can even use the '-i' option to process the file in place, which avoids using temporary files for the operation (saving a few more seconds).
i just want to know that how reliable is "replace.php" we have more tahn one servers and we are frequently taking backup from one server and restorinf them on the other servers so we have to replace the links with new ones. so i am thinking of putting this script in the end of restoration so that it will automatically run on every restoration ?????
Some courses if not most, have pictures in the title of every topic in the course. I am testing the replace function coz i need to change the site address. The pictures are still pointing to the old site name even after i used the replace method.
Are there any tables/columns which this function skips? What do i need to edit in this function?
Check this link out http://moodle.org/mod/forum/discuss.php?d=62959
I did this on the weekend twice and it worked a treat.
Oddly some of the urls didn't completely change until I had flushed the cache which can be done by logging into the site and editing a section with the old url and then exiting edit mode.
About 15 minutes from start to finish without issue.
I tried to type this into my url address but I got a 404 error.
moodle is installed in this directory:
so I would enter the following:
but I get a 404 error
can you advise me on this please?
If you have mysql5 you could try using a cursor - I'm not sure if you can do it to loop through tables, though.
Alternately, a really simple php script could do the trick. Pull the list of tables in, and loop through the update.