I am just about to get serious with my site after playing with various options. Naively I installed everything in /. Now I want to be able to change the Drupal version (and have dev installs) without the user knowing.
To be specific: I have made an exact copy of /* to /drupal/drupal473/. First I want users to use the /drupal/drupal473 installation as if they are using /. They should be blissfully unaware that the site has relocated to a new directory. Redirecting using /.htaccess is easy - I made a simple .htaccess with RewriteRule ^/?$ ./drupal/drupal473/$1 [L]. The redirection is clean - the user sees nothing amiss (ie url is as expected) however, once they click (or hover a link) they get the gory details: /drupal/drupal473/bla...
The point being that at some stage I will upgrade and this redirect will be to /drupal/drupal52/ or maybe /drupal/drupal52/newtheme, etc
(I have ssh access and lots of space, but no access to .http.conf, etc, use Apache2.0, php5, mod_rewrite, mod_alias...)
I am missing the point somehow: how do I get Drupal to use the correct url internally but present the nice url to the world?
Can anyone set me right. My site is compute.org.za.
Regards
David
Comments
=-=
drupals .htaccess file to rewrite the url
___________________________________________________________________________________________________
The search tool on Drupal.org really does work. This message has been brought to you by the letter X. Thanks for watching! : )
(no title)
This is not trivial. Check here how someone managed to do it in a clever way, using the $base_url settings in settings.php and then two different .htaccess files (one in the web root and one in Drupal) to fool the file system into fetching the real files correctly.
http://drupal.org/node/144643
I would suggest against this if you are going to run anything else under that installation. Too many complications. Consider using the main site as... main site, and to add subdomains from your cpanel, such as devel.example.com, pointing to different subdorectories, for your other needs.
My solution
Thanks for your advice. I persisted with my headstrong philosophy. Using your reference I developed the following which I thought I'd share:
(1) I installed various flavours of Drupal in ~/drupal/xyz with their own DB's set in xyz/sites//settings.php. In my case xyz is either prod(uction), dev(elopment) or old.
(2) I created the following ~/.htaccess
# Apache settings:
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
#If the requested uri is not the "undecorated" uri of the web
#server (no case) ...
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
#... add the http://www then redirect and leave [a 301 permanently redirected]
RewriteRule .* http://www.domain.com/ [L,R=301]
#If the url is the simple domain, simply redirect
RewriteRule ^$ drupal/prod/index.php [L]
#If the url points to a file in the right place already,...
RewriteCond %{DOCUMENT_ROOT}/drupal/prod%{REQUEST_URI} -f
#then rewrite and leave (I assume this is for the next htaccess to catch)
RewriteRule .* drupal/prod/$0 [L]
#Do the same for specific references to old
RewriteCond %{DOCUMENT_ROOT}/drupal/old%{REQUEST_URI} -f
RewriteRule .* drupal/old/$0 [L]
#... and dev
RewriteCond %{DOCUMENT_ROOT}/drupal/dev%{REQUEST_URI} -f
RewriteRule .* drupal/dev/$0 [L]
#If the url is a filename or directory send this to drupal (query string append)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* drupal/prod/index.php?q=$0 [QSA]
</IfModule>
(3) I used the recipe in 144643 for prod, making my production directories available from the domain without the directory
(4) for dev and old, I used the standard Drupal .htaccess with (focusing on just dev for convenience)
(4.1) ErrorDocument and DirectoryIndex wired to /drupal/dev/index.php
(4.2) RewriteRule ^(.*)$ /drupal/dev/index.php?q=1 [L,QSA]
(5) /drupal/dev/sites/default/settings.php has base_url set to http://www.domain.com/drupal/dev
Then the public site is accessible through the standard permutations of http://www.domain.com and the "development" and "old" sites available through http://www.domain.com/drupal/dev, etc.
My 2c worth!
Regards
David