Installing and upgrading help

how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."

 
This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.
Picture of Daniel Garcia Sanchez
how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Hello friends smile

I would like know if it is possible to remove this message from appearing on screen when accessing: mydomain.com/moodle instead of www.mydomain.com/moodle

"Incorrect access detected, this server may be accessed only-through x address, sorry."

I would like, if possible, to redirect directly to the cover of my moodle, without waiting for this message. I have asked for this in the spanish forum of moodle, and they said to me that I one way is creating a record "CNAME" but I don't know how create it, because when I try to create one record of this type from my panel of plesk, I have to give values to two parameters: domain's name and canonical name...sorry for my ignorance

Best regards and thanks in advance, Daniel

 
Average of ratings: -
Picture of Andrea Bicciolo
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup TestersGroup Translators

If you are working with Plesk, there are good chances you already have a CNAME record for www.yourdomain.tld with the following syntax on the DNS zone:

www.yourdomain.tld CNAME yourdomain.tld

That could be confirmed by the fact your web server answers to requests adressed to both http://yourdomain.tld and http://www.yourdomain.tld

In any case, in the CNAME example above, "yourdomain.tld" is the canonical name (and you should find it in the Plesk DNS zone as recordy type A with an IP address), while "www.yourdomain.tld" is the domain name.

 
Average of ratings: -
Picture of Howard Miller
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup Plugin developers
The underlying problem is that you can't do that.

Moodle will only work with one value of 'wwwroot' in config.php. You have to pick one and stick with it. You could arrange a web server re-write or redirect to ensure that any 'wrong' URLs get redirected to the front page of your Moodle with the correct URL, but you can't run with an alias.
 
Average of ratings: -
Picture of Daniel Garcia Sanchez
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

is possible change the waiting time of this message to 1000ms instead of 3000ms?

thanks, Daniel

 
Average of ratings: -
Picture of Howard Miller
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup Plugin developers
In lib/setuplib.php look for this line


redirect($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 3);


Change the 3 to 1.
 
Average of ratings: -
Picture of Daniel Garcia Sanchez
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Hey Howard! Thanks very much for your reply wink

 
Average of ratings: -
Picture of Gabriel R.
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

This approach only works if you are trying to access the moodle site root.  For example, on our moodle site, when a non-authenticated user accesses the site, they are presented with custom images that link to login and signup.

So, if our setup in config.php is "$CFG->wwwroot = 'http://www.mysite.com';", we would get this error message when trying to access mysite.com/, and with the above solution, it forwards nicely to www.mysite.com, BUT if we have linked our signup image to "mysite.com/login/signup.php", it forwards to www.mysite.com/ - but does not include the rest of the path.

 
Average of ratings: -
Picture of Hubert Chathi
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Plugin developers

If you control the link, why not just make it link to www.mysite.com/login/signup.php instead?

 
Average of ratings: -
Picture of Clarence Prudhoe
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Hi,

If you add the following instructions to your .htaccess file, it will force a redirect to http://www.mysite.com.   If you use this solution, you won't have to update the moodle code every time you update to a new version.

suphp_configpath /home/myroot/public_html/php.ini
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^fbcph.com [nc]
rewriterule ^(.*)$ http://www.mysite.com/$1 [r=301,nc]

This worked for me.
Clarence

 
Average of ratings: -
Sketch...
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Particularly helpful Moodlers

MDL-35099 would also be useful in this situation...

 
Average of ratings: -
On the jetty
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Thnaks to Clarence and the assistance of a collegue in our office we got the following code to work with the .htaccess file to redirect from http://www.myhost.com straight to http://myhost.com

 

suphp_configpath /home/myroot/public_html/php.ini
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^www.myhost.com [nc]
rewriterule ^(.*)$ http://myhost.com/$1 [r=301,nc]

 i.e. replace the myhost.com  with your domain name

Thanks

 

 
Average of ratings: -
hungry_kitten
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

It worked perfect for me! I changed it to 0 though. Thanks Howard!

 
Average of ratings: -
Picture of praveen gubbala
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

thanks alot... your solved my biggest worry... but how can i play those videos on an android mobile

 
Average of ratings: -
Picture of saeed abbasi
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

remember that, after changing the code, delete cache and temp folders in moodledata folder of your server

 
Average of ratings: -
Picture of Usman Asar
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Particularly helpful MoodlersGroup Plugin developers

No need for deleting cache's or any folders, changing to zero works immediately.

 
Average of ratings: -
Picture of Karishma Tiwari
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Hi,

Can anyone confirm with alias cannot be used on Moodle?

I am using Moodle 2.8, and i have setup an A record in my DNS, for the alias of my moodle server. The A record is pointing to the IP number of my server.


When i try to access my alias elearning.xxx.com, i get the error:

Incorrect access detected, this server may be accessed only through "http://xxx.xxx.net" address, sorry.


 
Average of ratings: -
Picture of Emma Richardson
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Documentation writersGroup Particularly helpful Moodlers

You need to change your config.php file to reflect the dns name instead of the ip address.

 
Average of ratings: -
Picture of Joseph Rézeau
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup TestersGroup Translators

Hi Daniel, Andrea and Howard.

I've just been confronted with this problem on my local moodle installation. In order for my desktop localhost moodle sites to be accessed from my laptop and tablet, I need to replace

$CFG->wwwroot   = ' http: //localhost/moodle21fork/moodle';

with

$CFG->wwwroot   = ' http: //192.168.1.10/moodle21fork/moodle';

where 192.168.1.10 is the IP of my desktop machine.

Now, when I log in to my moodle 21 test site, I get the obnoxious message:

Incorrect access detected, this server may be accessed only through "http: // 192.168.1.10/moodle21fork/moodle" address, sorry.
Please notify server administrator.
(Continue)

What is the point of that message, since it does not prevent access to my moodle site, after a few seconds' delay? By the way, the message is illogical, as it says the server can only be accessed through an address which is precisely the URL that has been typed in the browser. Weird!

Joseph

 
Average of ratings: -
Picture of Andrea Bicciolo
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup TestersGroup Translators

Hi Jospeh,

interesting point, yes the message could be better but according to your test it appears some logic is not working as expected.  You may want to  open a tracker issue for this?

 

 
Average of ratings: -
Picture of Hubert Chathi
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Plugin developers

AFAIK, the point is to prevent people from trying to publish multiple URLs to access the same Moodle site.  Moodle does not handle being accessed from multiple URLs well.  In previous versions, Moodle didn't check, and you would be able to use multiple URLs, but strange things could start happening.

 
Average of ratings: -
C'est moi :-)
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Documentation writersGroup Particularly helpful MoodlersGroup TestersGroup Translators

Hi,

Do you have some pointers about that?

Since 2/3 months, and after a domain change, i've put these lines in my config.php file, to allow my Moodle to be accessible from several (2) adresses (defined in apache virtualhosts) :

$CFG->wwwroot = 'http://default_old_domain/moodle';
if (isset($_SERVER['HTTP_HOST'])) { $CFG->wwwroot = 'http://'.$_SERVER['HTTP_HOST']; }

In fact, it automatically adapt's from the used URL to access the Moodle site.

Séverin

 
Average of ratings: -
Picture of Daniel Garcia Sanchez
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Finally I solved it by changing, in lib/setuplib.php:

redirect($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 3);

for

redirect($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 0);

Now, when I access in the way: mydomain.com , moodle redirects inmediately to the www.mydomain.com

Thanks to Howard, Daniel

 
Average of ratings: -
Picture of Rachel Fransen
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Thanks for posting this solution - works for me as well! smile

 
Average of ratings: -
Picture of William Stewart
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 
Worked PERFECTLY for me on Moodle 3.0.2+ and took less than 5 minutes to do!
 
Average of ratings: -
Picture of José Ángel Polo
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Thanks

 
Average of ratings: -
Picture of Willow Brooke
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Thanks Daniel! Yes

 
Average of ratings: -
Liko Puha profile pic
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Thank you! Worked beautifully for version 2.8.2.

 
Average of ratings: -
Picture of tim st.clair
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Plugin developers

I need to be able to DEBUG my skin using a variety of browsers. I run a mac, and moodle runs on MAMP just fine on the local machine. None of the current thread solves my problem at all.

In order to test other browsers, such as IE7 on Windows, I run virtualbox. This normally lets me access my own other non-moodle sites by using the 10.0.2.2 loopback address, which is part of virtualbox.

So on MAMP on MAC, I have to use the address http://locahost/moodle22/

On IE7/XP on VIRUTALBOX, i have to use the address http://10.0.2.2/moodle22/

But I get the warning Incorrect access detected, this server may be accessed only-through x address, sorry.

Perhaps there's some way I can set up a DNS server on the mac? So that I can make a reference to, say, moodle22.mybox.local as a domain name. Please note that this is my Air, it is where I develop, it is not a server. I do not want OSX Server.

I do not know how to do this on a mac, and I do not have a windows server that I could do it on. This is not live on the internet.

 
Average of ratings: -
Picture of Edmund Edgar
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Hi Tim.

If you want to make a hostname for testing that only works from one computer (or virtual computer), you can do it by editing the hosts file. On a Mac or Linux, this lives at /etc/hosts. On Windows, it lives somewhere like C:\Windows\System32\drivers\etc\hosts.

On the mac, add to your /etc/hosts file:

127.0.0.1    moodle22.mybox.local

On the Virtual Box, add to C:\Windows\System32\drivers\etc\hosts:

10.0.2.2    moodle22.mybox.local

 
Average of ratings: -
Picture of Kevin Phelps
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

You can also used "Bridged Networking" in Virtual Box so each system is given an actual IP address. That way you can run the server in either the host or virtual computer and set $CFG->wwwroot to the "server" IP address. You can then use the "server" IP address in the browser of both computers along with others on the network.

Edit: This solution may not work if you are not connected to the Internet, but should work if you have a non-Internet LAN.

 
Average of ratings: -
Picture of karthi R
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

in config.php replace the following in $CFG->wwwroot   


$CFG->wwwroot   = 'http://'.$_SERVER['HTTP_HOST'].'/urhostname';

 
Average of ratings: -
Tony Youens GreyMatter Training
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Dear all,

I was directed to this thread by my 123-Reg after raising a support ticket. I installed Moodle from their site yesterday to a subdirectory (which I called 'lms') and get the 'Incorrect access...' message. 

This occurs when I use the url http://www.mysite.co.uk/lms

Unfortunately my experience of using Moodle is at stage 0 so many of the answers here leave me more confused than enlightened (I've just enrolled on a Udemy course to learn more).

I did add some lines to .htaccess (the one in the lms directory) suggested by Clarence Prudhoe and got an error message.

The content of .htaccess prior to my meddling was:

AddHandler application/x-httpd-php53 .php .php5 

DirectoryIndex index.php

RLimitMem Max

Anyway I'm wondering if it would be better to delete the whole installation and install it directly from the Moodle site. That said I seem to struggle with the whole Moodle thing so I'm not sure about this.

Any advice on the level of, 'Moodle for the bewildered' would be gratefully received.

Tony


 
Average of ratings: -
Picture of Richard Oelmann
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

What does your config.php for the site have as the wwwroot address for the site?

 
Average of ratings: -
Tony Youens GreyMatter Training
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Hi Richard,

Thank you for getting back. At the moment frustration has got the better of me and I'm in the process of deleting Moodle on my website and will try uploading it manually (fraught with danger). 

However I fear I may still get the same problem and assuming this is the case I have a look at config.php and get back.

I'm assuming this all has something to do with my site using https and not plain old http.

Thanks again.


 
Average of ratings: -
Tony Youens GreyMatter Training
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

Hmm, after deleting the installation I thought I'd try a reinstall from 123-reg and perhaps obviously I get the same message.

So answering your question it says...

//=========================================================================

// 3. WEB SITE LOCATION

//=========================================================================

// Now you need to tell Moodle where it is located. Specify the full

// web address to where moodle has been installed.  If your web site

// is accessible via multiple URLs then choose the most natural one

// that your students would use.  Do not include a trailing slash

//

// If you need both intranet and Internet access please read

// http://docs.moodle.org/en/masquerading


$wstring = 'mysite.co.uk/lms';

$CFG->wwwroot   = 'http://' . str_replace ( '/mysite.co.uk', '', $wstring ) ;


I've changed my actual website name for mysite.co.uk. I'm assuming that's ok.

Thanks,

Tony

 
Average of ratings: -
Picture of Richard Oelmann
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Well, I don't recognise, or see the need for the $wstring and str_replace business. Why not just have the line as it is in the config-dist.php example file?

$CFG->wwwroot = 'http://mysite.co.uk/lms';

It is setting the wwwroot so I'm not sure there is a string to replace, so it may be that your wwwroot is not being set properly in the first place.

 
Average of ratings: -
Picture of Richard Oelmann
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Actually, looking at it properly, that string replace may not actually be doing anything because it is searching for /mysite and your string actually starts mysite with no initial slash, so it probably isn;t actually finding and replacing anything anyway. But even if it was, its intention appears to be to strip the domain bit out of the string, which isn't correct anyway.


 
Average of ratings: -
Picture of Howard Miller
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
Group Core developersGroup Documentation writersGroup Particularly helpful MoodlersGroup Plugin developers

I've seen this before. I think it comes from one of those installer scripts. Once again, download Moodle from moodle.org and install it properly and you won't have these weird problems.

You will have different weird problems clown

 
Average of ratings: -
Tony Youens GreyMatter Training
Re: how to remove the message "Incorrect access detected, this server may be accessed only through x address, sorry."
 

I've tried various different tactics but I always end up with an error message of some sort. 123-reg don't offer any meaningful support for Moodle so I'm looking at 'Squirrel Hosting' as a possible option.

Ah well...

Thanks to everyone.

 
Average of ratings: -