General help

 
 
Picture of Amer Hamade
Changing moodle site address
 
Dear All,
How can I change the address from http://oldname.com to http://newname.com WITHOUT breaking all the links in the courses, links for pictures/files...???

thnx
amer
 
Average of ratings: -
Picture of Iñaki Arenaza
Re: Changing moodle site address
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers
You need to search and replace those strings in your database tables.

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.

Saludos. Iñaki.
 
Average of ratings: -
Picture of Amer Hamade
Re: Changing moodle site address
 
Thank you Mr. Inaki. I always wait for your replies smile. But i need 1 more request, what do you mean by "dumping a copy of the database in a text file" and "restore the modified dump back into the database".

If you dont have time to explain, just lead me to somewhere i can get clear info about the issue.

thank you lots!
 
Average of ratings: -
Picture of Iñaki Arenaza
Re: Changing moodle site address
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers
You just do a database dump (a backup) using mysqldump or similar tools. That produces a text representation of your database contents (in a huge file if you have lots of records smile)

You edit that file and then restore (using mysql command line client, for example) your modified database back.

Simple yet effective.

Saludos. Iñaki.
 
Average of ratings: -
In my classroom
Re: Changing moodle site address
 

Hello

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. 

My question:

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:

(http://docs.moodle.org/22/en/Moodle_migration)

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  

http://supremeducation.com/studyonline/ 

to

http://englishusingsongs.info 

If so how?

Sincerely, 

Dominick Inglese 

 

 
Average of ratings: -
Picture of Rick O
Re: Changing moodle site address
 

I am on Moodle 2.2.2+ (Build: 20120419) and have a DNS entry so it points to http://moodle.myintranetserver.org instead of using the server's hostname. I dumped the moodle database but can't find any entry that points to the host name or ip address to replace to the DNS alias.

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.
Continue"

 
Average of ratings: -
Picture of Sandeep Gill
Re: Changing moodle site address
 

Hi Rick,

You need to change the following in "$CFG->wwwroot" in your config.php file. (This sits inside moodle root directory).

 

Cheers

Sandy

 
Average of ratings: -
Picture of Steve Power
Re: Changing moodle site address
 

Amer

I use PHPMyAdmin to edit the database directly calling a file with a number of SQL update commands of the form:

update mdl_resource
set alltext=(
replace(alltext,
'http://oldname.com',
'http://newname.com'));

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.

Regards
Steve

 
Average of ratings:Useful (2)
Picture of Amer Hamade
Re: Changing moodle site address
 
Hi Steve,
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 dead.

Do you think Mr. Inaki's solution better satisfies the needs of my department?

amer
 
Average of ratings: -
Picture of Steve Power
Re: Changing moodle site address
 

Amer

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!

Regards
Steve

 
Average of ratings: -
Picture of Amer Hamade
Re: Changing moodle site address
 
Steve,
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?

amer
 
Average of ratings: -
Picture of Steve Power
Re: Changing moodle site address
 

Amer

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.

Regards
Steve

 
Average of ratings: -
Picture of Iñaki Arenaza
Re: Changing moodle site address
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers
> 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.

For those Unix/Linux admins out there, using 'sed' to process the database dump makes the search & replace operation blazingly fast smile

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).

Saludos. Iñaki.
 
Average of ratings: -
Picture of Steve Power
Re: Changing moodle site address
 

Iñaki

Thank you for this. I am a Windows user but for some reason I had never thought to use "Search and Replace" my usual application for this type of job. I have been struggling editing the file in a text editor! S&R did the job very quickly.

Steve

 
Average of ratings: -
Me and Ray
Re: Changing moodle site address
 
Thanks for this SQL Steve, it will come in handy.

Does anone know a way of doing this more globally? Following will not work of course, but...along these lines and only at night
Update * SET (*)=replace(\1,
'http://oldname.com',
'http://newname.com'));

Timothy
 
Average of ratings: -
Martin in black and white
Re: Changing moodle site address
Group DevelopersGroup Documentation writersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers
See: http://yoursite.com/admin/replace.php

MAKE A BACKUP FIRST!!!!
 
Average of ratings:Useful (1)
Me and Ray
Re: Changing moodle site address
 
oooh, thanks, martin
 
Average of ratings: -
Picture of tm tm
Re: Changing moodle site address
 

hi Martin,

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 ?????

 
Average of ratings: -
Picture of Amer Hamade
Re: Changing moodle site address
 
Dear Martin,

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?

thank you,
amer
 
Average of ratings: -
Picture of Graeme Forrester
Re: Changing moodle site address
 

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.

 
Average of ratings: -
In my classroom
Re: Changing moodle site address
 

hello ~

I tried to type this into my url address but I got a 404 error. 

moodle is installed in this directory:

http://supremeducation.com/studyonline/ 

so I would enter the following:

http://supremeducation.com/studyonline/admin/replace.php   

but I get a 404 error 

can you advise me on this please?

Sincerely,

 

Dominick Inglese 

 

 
Average of ratings: -
Picture of David Barber
Re: Changing moodle site address
 
Timothy,

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.

David
 
Average of ratings: -
Picture of Azhar Ghani
Re: Changing moodle site address
 

Hi,

i want to put moodle login link on another website...

what would be script for incorrect password..

 
Average of ratings: -
Sketch...
Re: Changing moodle site address
 
Average of ratings: -