Moving Drupal from subdirectory to directory
anglophobe - April 19, 2005 - 14:50
Currently I'm testing out/configuring drupal on my site in a subdirectory, while my old site stays in the root of my html directory.
Is there an easy way to move drupal so the index is in the /home/me/html directory, while all the other files stay in /home/me/html/drupal?
Sorry if this is answered in another post, but I couldn't seem to find it.

What do you mean?
I'm not really sure what you're trying to say. If you mean that the front page appears at / and the second node appears at /drupal/node/2, I don't think you can do it. Frankly, I don't see why you would want to do it.
Trying to explain
Currently I'm using wordpress.
My wordpress index file is at http://domain.com/index.php and all of the config files and such are in the wordpress directory.
I'm a fan of clean directory structures.
I'd like to do a similar thing with drupal.
So, the drupal index.php page would be in /home/me/html and it would reference /home/me/html/drupal
If that doesn't work, I can just move the entire directory contents up one directory right?
Why not just
Why not just http://domain.com/drupal/
Easy workaround
If you have the ability to do this, why not create a subdomain (subdomain.yourwebsite.com) and install Drupal there. Then, once you're up to speed, have your main domain point to the subdomain (or mirror it) so that visitors to your main domain see what you've built on the subdomain.
--
mediagirl.org
I still don't understand.
Do you want URLs to be at example.com/drupal, or the included files in /drupal but the URLs at the root level?
The second is rather difficult and would likely require a lot of code changes. The first is just about what you've got now.
same question
I understand the orginal question, but don't see an answer that makes sense to me (at least).
If I presently have Drupal 4.6 set up with /home/me/html/drupal/index.php and I want to move index.php to /home/me/html/index.php and leave all the other Drupal files in /home/me/html/drupal to maintain a "neat" html directory what adjustment to what file will accomplish this.
With WordPress the adjustment is very straightforward to move the index.php at /home/me/html/wordpress/index.php to /home/me/html/index.php with the remainder of the WordPress files remaining at /home/me/html/wordpress. You just adjust the index.php with the move from ./wp-blog-header.php to ./wordpress/wp-blog-header.php.
Is there a similar adjustment that I'm just not seeing? TIA. Apologies if this has already been covered, but this seemed the closes thread to my question.
No
You can't just move index.php file without rewriting it. WordPress is not a complex CMS with a lot of interdependancies. WordPress is a product focused on blogging, while Drupal can do blogging with other stuff.
The adjust you need to make is in your Apache htaccess file. Look at the one downloaded with your Drupal install for the examples.
-also http://drupal.org/node/4810
-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide
thanks
Its .htacess time.
Just move sub to root?
I think I have a similar situation, but I'm hoping it's even simpler.
I have a test Drupal install (4.6.2) in domain.com/home. The old site is at domain.com. I'm ready to go live and I'll just delete the old site and move Drupal from domain.com/home to domain.com.
I'd rather not do redirects or mess with .htaccess. I just want Drupal in the root directory, the whole thing, with its directories and everything.
I see in /sites/default/settings.php there's this:
$base_url = 'http://www.domain.com/home';Is the whole process as easy as:
1.) Change that line in settings.php to:
$base_url = 'http://www.domain.com';2.) Drag all folders sitting in /home/ to domain.com?
Thanks for any advice before I do this!
There are maybe 50 entries in the current test site.
- Bradley
Where to put a test site?
Actually, while I'm asking, how can I avoid this in the future? There's usually an existing site up at domain.com (usually index.html or default.html or whatever). So could I somehow allow the old site to function while I work on the Drupal site until it's ready to switch?
Many ways to do it
There are many ways to do this.
You can either set up a site on your home machine or put one in a subdirectory on your hosting account. The former is much more powerful and generally better in the long run, but it takes more work to get started. If you do the latter, all you need to do when you're ready to switch is move the files and change the $base_url variable in settings.php.
I went looking for some info in the handbook, but I couldn't find anything.
How to manage mysite.com with Drupal installed in a subfolder?
I can't believe that this question hasn't a reply that goes to the point!
I'm also trying to have Drupal working on my site's root:
http//www.mysite.com
That's easy, of course! But the question is:
How to manage mysite.com with Drupal installed in a subfolder?
Eg. (this is what I want):
http://www.mysite.com/drupal .....Here's Drupal
http://www.mysite.com .....Here's my site
Why I don't want to install all the drupal directories in my site's root? It doesn't matter, I'm trying to know if this is possible ...
Thx in advance!
.................
Ravenpix
.................
Read the htaccess file for
Read the htaccess file for examples. This is a webserver setup question more than a Drupal one.
The default examples used to be set for using Drupal in a sub directory, but people complained that it was to confusing so it was changed.
In the mean time, I refer you to the handbook page that may help a little as well in addition to the htaccess file in the download.
-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain
My final solution
Yeah, you know, I like Drupal a lot. I downloaded it to a test directory on my website and poked around it a bit, trying to get the hang of it. Before I knew it, I'd converted my entire old site over to the drupal I had in my subdirectory.
I thought Well heck, I'll just copy everything over to the root so that I don't have to go through a bunch of re listing my url and all of that business.
My site worked like 10 minutes after that and started crumbling. Weird errors, strange layout, things disappearing or showing up wrong..it was a mess. I wound up having to wipe the whole thing out and start from scratch. It was a real chore (and a testament to how much I like this software) but Im 95% back up to speed now. Still a few things to add. Anyways, when I ran into problems I came here and searched high and low for help on transferring from one directory to the root directory and couldn't find anything...til now and now Ive already re worked everything.
In the next version of the handbook I hope there's a section for idiots like me that installed Drupal in a subdirectory and then transfered it over to the root directory so that no one else looses their website!
transfer
The only thing you need to change in a transfer is the baseurl in the settings.php file and any htaccess file rules you have set in regards to a sub directory. (This assumes file permissions are correct).
I have transfered a number of sites over and over again. To and from subdirectories and site roots. If you have a backup of your database, then you should be able to restore it. I suggest reading th ebest practices link in my sig.
-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain
Still confused
I have read this whole thread and also looked up the Handbook at the place indicated and I am no wiser as to how to do it...
What I have:
1. Installed drupal in mysite.com/drupal.
2. Would like to access Druapl from mysite.com directly.
What I have done:
1. Modified the .htaccess as suggested in Handbook.
2. Modified base_url as suggested in Handbook.
My question is which file (or both) out of index.php and .htaccess do I need to copy to the root directory?
Thanks!
this is still an open issue
this is a widely requested open issue. I'm linking all threads here: http://drupal.org/node/22336 , which will hopefully gather the troops ;). Please reply on /that/ thread, not this one.
(oh, and me too!)
you are confusing
the issue. To move an install, just move ALL THE FILES to the new driectory structure. Modify the settings.php (baseurl) and the htaccess file as appropriate to the new location.
Everything else is relative to this information uless you have hard coded it somewhere for some odd reason.
You do not move one file. Drupal is a CMS. Most of the files are needed o rit just all breaks. People keep giving the correct answer.
-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain
It may not be so clear
I have done all of the above steps, and am still not able to get this to work. I know it's not that difficult, but I've gotta wonder what I'm missing.
I set up the Drupal site in a subdirectory callled "cms." The owner of the site wants to lose the 'cms' portion of the URL. So I:
1. Copied the entire content of the 'cms' folder to the root folder;
2. Reset the base URL in the settings file to elminate the 'cms';
3. Have looked at the .htaccess file (now in the root folder), and have noodled around in tthere, but cannot find what might need to be to modify there (even after reding through your Best Practices Guide).
What exactly needs to be tweaked in the .htaccss file? I'm sorry to say that "as appropirate" isn't all that helpful.
Any further clarification would be very welcome.
htaccess is an Apache config
htaccess is an Apache config thing.
Look here: here for a copy of the original htaccess file
If you had Drupal in a sub directory, then you or someone modified it at some point
At a guess, yours looks something like
RewriteEngine on
# Modify the RewriteBase if you are using Drupal in a subdirectory and
# the rewrite rules are not working properly.
#RewriteBase /cms
and you want it to look more like the original which assumes Drupal will be in the root folder.
RewriteEngine on
# Modify the RewriteBase if you are using Drupal in a subdirectory and
# the rewrite rules are not working properly.
#RewriteBase /drupal
Though I am not sure why the guy running sites on IIS is answering this one. :)
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain
Thanks, but . . .
Thanks for the quick reply, but that didn't do it. Now I get a really fun error message:
warning: call_user_func_array(): First argumented is expected to be a valid callback, 'node_page' was given in /home/cawrecyc/public_html/includes/menu.inc on line 354.
Any (nice) thoughts?
Hmm... if you dumped
Hmm... if you dumped everything into the webroot, the default .htaccess should work ok, with the RewiteBase commented out. And if it worked before in a subdirectory, then the problem must be some small detail.
Is your settings.php in 'sites/default' or in another 'sites' subdirectory with a different name?
And did you by any chance leave a trailing slash in the base url in settings.php?
All is as it should be . . .
at least with those files.
Rewrite base is commented out (and it did work in the subdirectory);
settings.php is in sites/default;
No trailing slash on the url in settings.php.
I've even reloaded the default .htaccess file in case screwed anything up in there, but nothin' doin'.
What else could it be...
What else could it be...
Is the old cms directory still there with the same name? Since the error message you are getting is coming from Drupal, at least make sure that it does not come from the old one.
Had you done any tricks to redirect to the cms directory when it was there, so that the visitors wouldn't have to type 'cms'? Any leftovers from that?
I am not trying to be helpful, I just like troubleshooting mysteries :)
I wish I knew . . .
I appreciate your inquiry, even if it is just idle interest.
A parallel site is up there still in the cms subdirectoy. The site owner hated the old site so much he wanted to pull the trigger on the new one, despite my warnings of potential problems.
No redirects in the cms folder. Nothing fancy. All I did before was have the index.html file redirect to the cms folder. And the error message indicates the files on the root, not in 'cms'.
It's not this complicated, right? I'm just missing something really basic, yeah?
Here is something which
Here is something which might help (or not)
http://drupal.org/node/23030
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'node_page' was given in D:\Web\GAP2\drupal-4.6.0\includes\menu.inc on line 354.
They say that the node module was not loading, they report that it was cured by itself and they blame throttling.
Interesting . . .
Now I get a different error message. This is good! I'll try to run this down then report back here with what I find.
Thanks!
Finally . . .
Finally got the solution.
First, the embarrasing stuff. I was getting errors because I had not fully ported modules as I had thought. Might have been due to server time-outs . . . or just plain operator error.
Once I got rid of the error messages, I was back at square one: home page appears, but nothing else. Finally decided to try adding in "?q=" ionto the URL, and, voila, pages appeared. Once I discovered that, I could get in to admin > setings, and enable clean URLs (this was necessary as the site nav is hardwired).
Only, now I was getting the error that I needed to talk to an admiistrator to be able to use modRewrite. This didn't make sense, as it was working when the .htaccess file was in the subdirectory.
It turns out that my ftp program (Dreamweaver) was corrupting the .htaccess file. I wasn't able to get Fetch to find it, so I modified the file name by removing the "." at the beginning of the file name (htaccess), uploaded it, and changed the name back. And that did the trick.
So, ultimately, it is as simple as changing the settings.php file and .htaccess file . . . but there are, for some of us, a few steps in between.
Thanks to all who helped.
Test site & live site
I am converting a static html site to drupal for someone, which is currently setup like: www.domain.net.
I would like to have the new drupal powered site at www.domain.net (after copying all html files/images) or www.domain.net/content and the test installation of drupal at www.domain.net/drupal.
The host is Earthlink, I don't know if they have cPanel or phpMyAdmin. They may have to move their site to a new host.
So the settings.php fiel would look like:
$base_url = 'http://www.domain.net';
or
$base_url = 'http://www.domain.net/content';
and the test installation
$base_url = 'http://www.domain.net/drupal'; correct?
When I am ready to copy the site and move it from http://www.domain.net/drupal to http://www.domain.net, the only thing I have to change is the url info in settings.php from the test installation and restore the database?
Paths in system table make moving a site more complex
I had a site where I hadn't switched the domain over yet. I was working out of www.provider.com/~mydomain/ for a while and then I transferred the host name and created a subdomain for my drupal install (test.mydomain.com).
old sites directory:
default/
provider.com/
new sites directory:
default/
test.mydomain.com/
When I went to view the site at test.mydomain.com, a story I added displayed but no theme and no menu and no error message. Weird. I searched around drupal.org and found this thread, but my issue seemed different so I opened up drupal's database and started looking for hardcoded paths.
Inside the system table were some entries that include paths to modules:
sites/provider.com/themes/chameleon/cha...
sites/provider.com/modules/tinymce/tinymce...
sites/provider.com/modules/civicrm/mod...
It seems that some modules and themes store path information that is site specific thus making it more complicated to move an installation from directory to another. When I changed provider.com to test.mydomain.com everything started working just fine.
Is this expected behavior? Did I do something wrong/unexpected to cause it? Or should these modules/themes play a little nicer?
These paths are relative to
These paths are relative to drupal's base directory. They are produced for all modules and themes which you install under "drupal/sites/sitename/modules" and "drupal/sites/sitename/themes".
I can see how this could be a problem with changing site names. The alternative for more flexibility is to install all modules and themes under "drupal/modules" and "drupal/themes" and enabe the ones you want for each site. The price is a little clutter, of course.
hi, i moved my site from
hi,
i moved my site from subdir create to the root. how come the links for the old configuration works, for instance; www.example.com/subdir/?q=node/39. but the interesting thing is it does only work both for ?q= not the clean urls. how can i fix this?
powered by Drupal www.universideliyiz.biz
On 5.1...
This thread shows up in searches, so I think it's a good idea to add more up-to-date information to it :)
Using Drupal 5.1, I've just moved my entire Drupal folder to a subfolder, and back again to the root folder of my webserver. It worked fine in the subfolder at the new URL, and still fine back at the root folder and the main url.
Can we install drupal in
Can we install drupal in
domain.com/drupal
but remove the /drupal/ portion from the url and serve the pages from root?
So that
domain.com/index.php
shows the drupal site?
Can this also be done on a multi sites setup?
For the answer to that, see
For the answer to that, see http://drupal.org/node/131906 -- but I don't know about multiple sites.
Thanks. I installed drupal
Thanks.
I installed drupal in /drupal/ folder. With this htacess, I can access drupal from the root directory now.
But how to remove the /drupal/ portion from the url?
More here http://drupal.org/node/22336
This thread is about moving
This thread is about moving the entire drupal folder to another folder.
This is a very old question,
This is a very old question, and from all that I have read I believe it is not possible to install Drupal in a subdirectory and access it as if it was the web root without displaying the subdirectory -- except if you can do (1) below.
Certainly not with apache rewrites, because they actually change a request for the web root to a request for a subdirectory, and that subdirectory is displayed.
Possible solutions:
1. Make Drupal's subdirectory the web root of another domain, if your hosting setup allows that, and use that other domain instead. Some hosts such as site5.com make this very easy, using domain pointers which make any subdirectory you want a web root for a new domain.
2. Try using a bunch of symlinks in the web root which point to the important files and subdirectories of Drupal. This is tricky to work, and the symlinks already make the web root messy, which defeats the purpose.
3. An extended redesign of Drupal so that it only has an index.php and a .htaccess file in the root and everything else in a subdirectory. This is not available.
Works fine for me with
Works fine for me with Drupal 5.1
I have Drupal in a subdirectory and with an .htaccess in the root folder I can access it as if it were in the root -- at www.example.com instead of www.example.com/drupal.
Details in the other thread.
Aw.... crud. I just realized
Aw.... crud.
I just realized what you mean -- the site is visible at www.example.com, but Drupal still generates its own URLs with Drupal in them. :(
Yes... the Apache rewrite
Yes... the Apache rewrite changes the user's request and adds "/drupal" to it.
That's how the site is accessed.
I was able to get this to work
See my comments here.
Can we do this in a multi
Hi,
You wrote RewriteRule ^/(.*) /drupal/$1 [L]
I can't get that to work.
But these 2 seems to work.
RewriteRule (.*) /drupal5/$1 [L]
RewriteRule ^(.*) /drupal5/$1 [L]
I am not sure about these. Which is right? Will there be any conflicts with modules or files?
Also, if I install a forum and wordpress in /forums/ and /blog/, I think this method will cause a problem?
Root
- /drupal/
- /forums/
- /wordpress/
And, can we do this in a multi site setup?
I also like to know if this
I also like to know if this configuration supports multisites.
It depends, what multisites
It depends, what multisites exactly?
Multisites work by comparing the requested URL with the names of the settings directories under /sites.
This apache rewrite adds "/drupal" to the requested URL.
If the multisites identification does not conflict with that, it might be ok. It may take some testing.
Using RewriteRule in a mixed environment
Well, I'm assuming the installation is in "/drupal". If you have it in /drupal5, then it would need to be changed accordingly. Or perhaps you have RewriteBase defined which then changes the URL content.
Your two examples are equivalent since RewriteRule matches against the entire URL (with the "http://www.example.com" removed). The latter may be preferred for clarity and potential efficiency since it states that the regular expression must match the beginning of the URL.
I too am using Drupal in a mixed environment, merging it into my site with existing files along side Drupal. This requires a more complex .htaccess file; here is what I'm using:
# Rewrite base to strip leading /
RewriteBase /
# Redirect root dir to Drupal top page
RewriteRule ^$ /drupal/index.php [L]
# Skip existing non-Drupal files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Existing Drupal files/directories (e.g. images, css)
RewriteCond %{DOCUMENT_ROOT}/drupal/%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/drupal/%{REQUEST_URI} -d
RewriteRule ^(.*)$ /drupal/$1 [L]
# Otherwise rewrite as a Drupal query (Clean URLs)
RewriteRule ^(.*)$ /drupal/index.php?q=$1 [L,QSA]
I'll walk through this a section at a time.
This strips the leading / from a URL (e.g. /some/dir/file.php -> some/dir/file.php):
# Rewrite base to strip leading /RewriteBase /
This redirects the empty URL (formerly "/") to the Drupal top page:
# Redirect root dir to Drupal top pageRewriteRule ^$ /drupal/index.php [L]
This checks to see if the requested URL already exists (all non-Drupal files/directories).
(The '-' in the RewriteRule means don't perform any substitution.):
# Skip existing non-Drupal files or directoriesRewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
Since the URL doesn't exist, check to see if it exists in the Drupal directory - if so, use it. Had to play some games here to split up the URL and insert "drupal" in the middle. The DOCUMENT_ROOT may not accurately reflect the actual file path - especially if aliases have been used. You may need to use the actual path to the drupal directory instead:
# Existing Drupal files/directories (e.g. images, css)RewriteCond %{DOCUMENT_ROOT}/drupal/%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/drupal/%{REQUEST_URI} -d
RewriteRule ^(.*)$ /drupal/$1 [L]
Finally, since none of the above conditions were satisfied, assume it to be a Drupal clean URL that needs to be converted into a query:
# Otherwise rewrite as a Drupal query (Clean URLs)RewriteRule ^(.*)$ /drupal/index.php?q=$1 [L,QSA]
Note that all of this assumes that Drupal is the default application and is all rather fragile. It will break if Drupal uses the same path of an existing application. For example, /forums/... and /blog/... as in your environment would be reserved paths that you could not use in Drupal.
I've been using this for several weeks and it seems to work without a hitch so far.
I haven't tinkered with multi-sites yet so I'm not quite sure how they work so I don't know how this would affect that environment.
this is a widely requested
this is a widely requested open issue. I'm linking all threads here: http://drupal.org/node/22336 , which will hopefully gather the troops ;). Please reply on /that/ thread, not this one.
____________________________
Insurance Center