I have kind of a strange/unique problem (I think). My host uses Ensim, which automatically forwards www.domain.com/user and www.domain.com/admin to it's back-end control panel interface. Obviously, this interferes with Drupal, since any of the clean URL's that start with either of those two won't work.
Where is this stuff kept (i.e. which module or include file)? Is there a way to change the URLs that Drupal uses?
I thought of using mod_rewrite, but it looks like the hosts re-directs take precedence -- i.e. my .htaccess file with mod_rewrite doesn't get read before the redirect.
Bright ideas appreciated...
Comments
maybe try the redirect.module?
it is on the download page
Nope
No -- the URLs are re-directed at the Apache level, set globally for all virtual hosts on the system. Those two URLs never even make it through to Drupal.
--
Boris Mann
rewriting links
Because most (or all) modules use common functions to create links, this could be done by modifying those functions.
The following seems to work on my system (tho i haven't done much testing):
in includes/common.inc, add this to the beginning of function url():
And add this to your .htaccess file, before the existing rule:
I can't garantee this will solve all problems, but its a start.
Frickin' Brilliant!
Nice work! That exactly did the trick for me. I added an else if that did the same thing for "user", renaming it to "usr".
That did indeed solve all the problems. Two thumbs up.
--
Boris Mann
since you seem to be in the same boat as me...
does your .htaccess file look like this:
I'm using drupal/ as my Drupal directory.
Works fine
Yes, my .htaccess looks like that. The fix worked perfectly for me. One thing, you'll need to move the two rules (administration and usr) to the top of your .htaccess file, before the other rules.
You did edit your common.inc file as mentioned above, didn't you?
Email me directly at boris AT bmannconsulting.com if you continue to have problems.
--
Boris Mann
Phew
Thanks, guys, I thought I was going to be screwed here. (On MediaTemple... they use the Ensim WebControl panels as well...)
New method
Since the earlier comments, global URL aliasing has been made available in Drupal. You might check that out as an option to avoid having to patch code.
See the help in path.module.
path's conf.php sample doesn't work
Some help here would be appreciated since following the sample from path.module's help page does not work. I've since modified the sample for this case to:
This properly rewrites all /admin links as /administration, but it *obliterates all other links.* Every link that does not lead to the admin area is turned into a link to the root/homepage of the site, destroying all navigation. (cvs/4.5-rc)
buller? buller?
anyone?
i'd love to get this hack out of common.inc, but unless someone can help with getting this feature of path.module to a) support more than one rewrite, i.e. admin->administration AND user->usr and b) prevent it from destroying other links, it looks like i'm stuck hacking common.inc to get this done.
well, test
I'm not really familliar with php so this is perl syntax, but you'll get the principle
To See the help for path.module
People affected with this need the hack just to get to path.module (such as myself). I had this hack working well under 4.4.2, but now that I have upgraded to 4.5, it's not working.
So I'm looking now, in the path.module help.
To get as far as I am now, one has to:
(1) Hack the common.inc file as shown above.
(2) get the .htaccess file edited - not as shown, but like this:
Note - the administration rewrite is ***immediately*** after 'Rewrite Engine on' on the third line. This is the result of the responses above.
Will write more as I work on this.
Folks, this is a really common problem and we need a better solution than "go downstairs, break down the door to the disused lavatory with the sign 'beware of jaguar' and look in the bottom drawer of the filing cabinet. The solution for this... whatever it is... needs to be in the installation guidelines so that anyone can have it on hand during installation.
I'll add it if I find a solution, but I would hope that someone else would as well. ;-)
Fixed.
Using the above hacks, I gained access to the administration pages on my site through this link in web browser:
This allowed me to gain access to the administration page for url aliases.
There, I added a url alias.
This alias was of form:
Existing system path: admin
New path alias: administration
I have verified that I can still access the web console provided by the ISP using
I then reverted common.inc and .htaccess to the original files that are downloaded.
It is important to note that it appears one must hack this to get to the url aliasing. Then one must un-hack this (or not) to assure a stable base.
I'll think on this a bit before I write up a feature request/bug report. I understand that the administration issue is somewhat inflexible for security reasons... but I also understand that ISPs commonly use admin for this purpose.
I'm thinking 'drupaladmin' may be a better url to use in the future...
sort of worked
Since standard url aliases are single page aliases only, this works for any link that goes straight to /admin but not for any that go to, say, admin/node.
I really, REALLY wish someone would just post a working example of this path.module global rewrite function that supported MORE THAN ONE PATTERN. We could easily take it from there.
Actually...
If you revert your files as I mentioned, the single page alias problem should go away.
no
no it doesn't. believe me, i've tried. i'm looking at it right now after adding url aliases and reverting common.inc and removing extra directives from .htaccess -- this simply isn't enough.
added: admin aliased to drupaladmin
added: user aliased to users
only the main administration page link is changed, the admin items underneath it are not (still /admin/settings for example). the user links on the posts themselves ("Submitted by...") are unchanged, for the same reason.
Fixed with httpd.conf rewrite
I ran into this on my first setup of Drupal; the 'clean URLs test' kept varfing on /admin/settings. Someone gave me the hint, and sure enough I have an /admin alias in my global config.
The Drupal path module and alias setting (4.7.5) didn't help. I fixed this, though, by adding a single RewriteRule to my Drupal virtualhost stanza:
RewriteRule "^/admin(.*)" "/index.php?q=admin$1" [PT]FWIW.
This works great in local on
This works great in local on windows , but does'nt work on online linux os
Easiest Fix
There's no need to modify your common.inc or .htaccess to fix this problem. Simply do the following:
And although the rest of your administration links will still have the admin/ path they will all still work perfectly. So I really don't see how that could be any sort of problem.
Thank you, this worked
Thank you, this worked really well for me on my Ensim box.
This was an interesting
This was an interesting read. I used ShiftThis' instruction and it worked perfectly.
I use MediaTemple and they recommended putting my site in var/www/html/exampleurl.com instead of where my files are now in var/www/html/
This broke the site so I reverted back to var/www/html and used the fix noted by ShiftThis. That was perfect, thanks for the great support!
the method by shiftthis is
the method by shiftthis is not working in 4.7 though.
the /admin directory worked, but all subdirectories under /admin are not working.
I want a fix for this as well
I'm on Mediatemple and I'm sick n tired of their admin system not working..
Please can't anyone present a fix for 4.7 that sort this problem out!
I'm on 4.7 and it's working
I'm on 4.7 and it seems to be working ok for me. . . .
Under Existing system path:
I have admin (with no trailing slash)
I have administration set as the alternative path. Hope that helps . . .
This didn't work for me until...
This wasn't working for me - when I submitted my log in, I was still sent to my host's user log in page.
I then switched off clean urls using SQL:
UPDATE variable SET value = 's:1:"0";' WHERE name = 'clean_url';
DELETE FROM cache;
This allowed me to log in using www.mysite.com/?q=user and I could navigate to www.mysite.com/?q=admin/path to set up the URL aliases as described above.
I then switched clean urls back on and now, fingers firmly crossed, I seem to be back in business.
ShiftThis Rocks!
Thanks ShiftThis. Your post from March 2, 2005 Worked perfectly on Ensim with Drupal 5.0
Matt Dolphin
www.mattdolphin.com
Easiest Fix
Well done ShiftThis. I was experiencing the same problem described with Ensim and Drupal 5.1.
I used the URL Aliasing module to create the new paths:
user -> usr
user/password -> usr/password
admin -> administration
The system works fine now. The best part is that the tabs in the user login pages automatically reflect the updated aliases.
For those who want to create the new aliases in Drupal 5.1, the address is:
http://www.yoursite.org/index.php?q=admin/build/path
Thanks for your help
Thanks to all those here. My host uses Ensim and this has got me out of trouble.
This is cool
Nice work.
Change it in Ensim instead of in Drupal
I went the opposite route: I changed the redirects in Ensim instead.
Edit the following file:
/etc/httpd/conf/virtual/site** (where ** is the site number)
For instance, since I only have one site setup in Ensim (for a multi-site Drupal install), mine is site1 and thus I did:
vi /etc/httpd/conf/virtual/site1Then look for all the RedirectMatch lines. You could either comment them out completely or I just changed the alias as bolded below. Instead of Ensim redirecting example.com/admin, it now redirects example.com/siteadmin. Likewise for example.com/siteuser
RedirectMatch ^/siteadmin/?$ https://000.000.000.000:19638/siteadmin/?ocw_login_domain=example.com
RedirectMatch ^/siteuser/?$ https://000.000.000.000:19638/siteuser/?ocw_login_domain=example.com
Make the changes and save then restart httpd.
There were two sections in my conf file that had to be changed for a total of four RedirectMatch lines changed.
There is a possibility that if you edit the site in Ensim, these edits may get overwritten, but I much prefer making the change in Ensim rather than in Drupal.
My experience with hosts
My experience with hosts using Ensim is that configurations frequently get over-written.
.htaccess and Path module
I needed to redirect http://www.oldsite.com/admin to http://www.newsite.com/admin/
and use Clean Urls so that http://www.oldsite.com/ could be indexed by a search engine that doesn't like ?q=.
After much research I used a mixture of .htaccess and the path module
in the .htaccess I did the redirect
RedirectMatch permanent /admin$ http://www.newsite.com/admin/
RedirectMatch permanent /admin/$ http://www.newsite.com/admin/
Using the RedirectMatch with the $ to indicate the end of the line anchor.
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteRule
http://httpd.apache.org/docs/1.3/mod/mod_alias.html#redirectmatch
It therefore doesn't redirect /admin/build etc.
Using the path module I changed admin to administration
seems to work
Path module fix for Admin directory problem
I have the path module enabled (one of the core optional modules, I think?). On all of my Drupal sites the url domain.com/admin/path produces a Page Not Found error.
Am I missing something here??
Cheers
about changing the admin url
How I can change the admin url for example
http://www.example.com/?q=admin
to
http://www.exmaple.com/?q=xyz
Is the .htaccess is the only solution or we have to write code as the drupal api suggest to use function custom_url_rewrite.
Please suggest me the easy way.
about custom admin url
I found one code for customising the admin url
function custom_url_rewrite($op, $result, $path) {
if ($op == 'alias') {
if (preg_match('|^admin(/{0,1}.*)|', $path, $matches)) {
return 'config'. $matches[1];
}
}
if ($op == 'source') {
if (preg_match('|^config(/{0,1}.*)|', $path, $matches)) {
return 'admin'. $matches[1];
}
}
return $result;
}
The problem with the code is that it creates the url but it shows the login at both the location config as well as admin location.Please suggest the solution for admin only so that user are not able to access the admin login page.
The above solution uses
The above solution uses custom_url_rewrite which has been separated to:
custom_url_rewrite_inbound
custom_url_rewrite_outbound
for Drupal 6.
Has anyone tried to implement the same code using these new functions for Drupal 6?
fix for Drupal 6
The following works for drupal 6: (Just add it to the end of the settings.php file)
doesn't block access to /admin
This suggestion doesn't block or send the user a 404 page if they "guess" domain.com/admin. Any way to do that?
@shift this.
Nice work.
D7
I have created a small module doing this for D7 : Rename admin paths. (I need some reviews so ... ;)
Raphael