1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Changing the admin URL?

Discussion in 'XenForo Questions and Support' started by Ryan McAdams, Dec 1, 2010.

  1. Ryan McAdams

    Ryan McAdams Active Member

    Do any of you know how to possibly change the admin URL?
     
  2. Dean

    Dean Well-Known Member

  3. Ryan McAdams

    Ryan McAdams Active Member

  4. Dean

    Dean Well-Known Member

    My mind is a bit fuzzy at the moment. Perhaps someone else?
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  6. Ryan McAdams

    Ryan McAdams Active Member

    I want to hide it. I dont want it to be a publicly known URL.
     
  7. Netsultants

    Netsultants Active Member

    This is a security measure suggested by another forum sw.
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Ok. This requires getting into the code. This is the relevant code:

    library/XenForo/Link.php

    Code:
    	public static function buildAdminLink($type, $data = null, array $extraParams = array())
    	{
    		$type = self::_checkForFullLink($type, $fullLink, $fullLinkPrefix);
    
    		$link = self::_buildLink('admin', $type, $data, $extraParams);
    		$queryString = self::buildQueryString($extraParams);
    
    		if ($queryString !== '' && $link !== '')
    		{
    			$append = $link . '&' . $queryString;
    		}
    		else
    		{
    			// 1 or neither of these has content
    			$append = $link . $queryString;
    		}
    
    		if (($hashPos = strpos($type, '#')) !== false)
    		{
    			$append .= substr($type, $hashPos);
    		}
    
    		$outputLink = 'admin.php' . ($append !== '' ? '?' : '') . $append;
    		if ($fullLink)
    		{
    			$outputLink = $fullLinkPrefix . $outputLink;
    		}
    
    		return $outputLink;
    	}
    
    You can see this line in there which specifies the file name:

    Code:
    $outputLink = 'admin.php' . ($append !== '' ? '?' : '') . $append;
    
    If you change the file name here and then rename the file on your server then that will change the location of the Admin CP.

    If you post a request in this forum then maybe some one can make an addon for this so you don't have to edit the files.
     
  9. Ryan McAdams

    Ryan McAdams Active Member

    Ya.. but regardless of software at all this is a good best practice.
     
  10. Forsaken

    Forsaken Well-Known Member

    Obscuring the URL will not stop someone from accessing your admin panel, as they would have already brute forced the pass, or they would have gained it some other way.

    And unless you're intending to change the link in the moderation bar, they'd still know the URL in the end.

    Using htaccess to secure the file, or limiting it to your IP only is more secure than changing the file name/location.
     
    Dodgeboard and Shadab like this.
  11. Brogan

    Brogan XenForo Moderator Staff Member

    You can always use .htaccess as Forsaken has suggested.

    Set up the password file using cPanel and then enter this in your .htaccess file:

    Code:
    <Files admin.php>
    AuthType Basic
    AuthName "ACP"
    AuthUserFile "path to passwd file"
    Require valid-user
    </Files>
    Change path to passwd file to the actual password file path.

    If you want to limit it to your IP address then use this:
    Code:
    <Files admin.php>
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
    </Files>
    
    Change 127.0.0.1 to your IP address.
     
    M@rc, Jake Bunce and (deleted member) like this.
  12. dono

    dono Member

    @brogan

    The requested page could not be found.

    I used
    Code:
    <Files admin.php>
    AuthType Basic
    AuthName "ACP"
    AuthUserFile "/www/.htpasswd"
    Require valid-user
    </Files>
    using cPanel.. any idea ?
     
  13. Brogan

    Brogan XenForo Moderator Staff Member

    I can only assume the path to your password file is incorrect.

    For reference, mine looks something like this:
    AuthUserFile "/home/domain/.htpasswds/public_html/forum/passwd"
     
  14. Slink

    Slink New Member

    Its easy.
    Just change your admin.php to anyname.php

    Now go to
    Code:
    /library/XenForo/Link.php
    And find the following line
    Code:
    $outputLink = 'admin.php' . ($append !== '' ? '?' : '') . $append;
    And change the 'admin.php' to 'anyname.php' .

    And you are done.
    Give me feedback. Is this worked for you?
     
    adwade likes this.

Share This Page