Hi,

I need to rename the /admin folder, so when someone tries to "guess" it he will get to a 404 page.

I tried to use custom_url_rewrite_inbound and custom_url_rewrite_outbound (http://drupal.org/node/2476), as well as the path module, but the /admin was still accessible.

Is there any solution?

Thanks!

Comments

adambg’s picture

no one...?

adambg’s picture

OK finally after few hours of heavy digging, I found that there is a bug with globalredirect module and custom_url_rewrite_inbound causing it an endless loop.

Anyway, I had to apply the following patch http://drupal.org/node/327695, included here:

Index: globalredirect.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/globalredirect/globalredirect.module,v
retrieving revision 1.1.2.4.2.5.2.14
diff -u -p -r1.1.2.4.2.5.2.14 globalredirect.module
--- globalredirect.module	22 Dec 2008 10:34:32 -0000	1.1.2.4.2.5.2.14
+++ globalredirect.module	11 Sep 2009 16:52:39 -0000
@@ -129,6 +129,15 @@ function globalredirect_init() {
 
     // Find an alias (if any) for the request
     $alias = drupal_get_path_alias($request);
+    
+    // if the returned alias is exactly the same as the request,
+    // that means that there isn't an alias in url_alias table
+    // so now we check for custom_url_rewrite_outbound
+    if ($alias == $request && function_exists('custom_url_rewrite_outbound')) {
+      $options = array();
+      custom_url_rewrite_outbound($alias, $options, $_GET['q']);
+    }
+    
     if ($prefix && $alias) {
       $prefix .= '/';
     }

In addition, to block hackers accessing /admin and /user I added the following code to the end of the custom_url_rewrite_inbound function at settings.php:

	if (preg_match('|^admin(/{0,1}.*)|', $path, $matches)) {
		$result = '404.html'. $matches[1];
	}
	if (preg_match('|^user(/{0,1}.*)|', $path, $matches)) {
		$result = '404.html'. $matches[1];
	}

Hope this helps someone...

espirates’s picture

admin is not accessible anyway so why would you need to do this ?

This is the message one would get if they tried to guess it

Access Denied
You are not authorized to access this page.

vangelisp’s picture

but a guest can see the admin theme, which for my cases is different than the frontend, and which personally isn't nice.

I'll try adambg's way.