I have two drupal sites with one codebase, one in the root and one in a subdirectory en. I am able to have clean urls with the site at root www.example.com, but not able to do so www.example.com/en. Looks like the setting in .htaccess below takes care of the root

RewriteBase /

Is there a way to do RewriteBase per directory basis, something like:

RewriteBase /


RewriteBase /en

Please advise, thanks a lot.

Lou

Comments

london3’s picture

Have a look in the .htaccess in your root directory. It may be hidden on some systems as it start with a dot.

If you are using several sites. You have to repeat your code

First you handle the root. It is there by default. At the end just before

You put in the following lines

RewriteBase /drupal
# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

You can do that one time for each Directory/drupal installation.

I never tried this as it is not needed on my servers.

Good Luck!

Are Casilla
http://astartelecom.com - Independent VOIP Telecoms Broker. Consulting in Asterisk and Drupal
http://astbill.com - Billing, Routing and Management software for Asterisk and MySQL. Running on Drupal
AstBill DEMO: http://demo.astbill.com

conbry’s picture

Are,

I have Drupal installed at root of www.example.com and created a second site for www.example.com/en with / public_html / sites / example.com.en / settings.php pointing to a secondary database. And, I created a symbolic link to link en back to the root public_html.

The site www.example.com works with clean urls, but the www.example.com/en does not. If the using clean urls is enabled at setting for en site, it woutld give error:
"It appears your host is not configured correctly for Clean URLs. Please check for ModRewrite support with your administrator."

Since I only have one .htaccess file, I tried to do something like, without success:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

RewriteBase /en
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

By doing so, the www.example.com/blog actually points to www.example.com/en/?q=blog behind the scenes

Thanks a lot for your help.

Lou

conbry’s picture

Is it possible to have a clean url and multiple sites with one codebase? Has anybody done so successfully?

Thanks,

Lou

bonobo’s picture

You need to do two things --

1. Set up the symbolic link from the subdirectory back to the root directory of your drupal install

2. Make sure you have the correct folder name in your sites directory -- ie, www.example.com.en for http://www.example.com/en -- and then, of course, you need to make sure that the settings.php file is configured correctly

One other thing that was recommended to me as a best practice -- keep the primary install for a domain name on a multi-site install in the "default" folder in the "sites" directory.

For a more detailed explanation, go here.

Hope this helps.

Cheers,

bonobo

-------
http://www.funnymonkey.com
Tools for Teachers

conbry’s picture

Thanks. I was able to run multiple sites with one code base. However, I can enable clean urls for only one site. Is it possible to have clean urls for all sites?

Thanks a lot.

Lou

bonobo’s picture

Currently, I have multiple sites running with clean urls off one codebase.

I only have one .htaccess file -- it resides in the root directory of the base install.

Cheers,

bonobo

-------
http://www.funnymonkey.com
Tools for Teachers

conbry’s picture

I have exactly what you recommended:

sites/defalut for the primary site: www.example.com
sites/www.example.com.en for www.example.com/en, pointing to a different database.

A symbolic link was created to link en back to the root where Drupal was intalled.

I changed the following in .htaccess:
# the rewrite rules are not working properly.
RewriteBase /

I was able to set clean urls for www.example.com.

www.example.com/en works, but, it would generate error when I try to enable clean urls:
"It appears your host is not configured correctly for Clean URLs. Please check for ModRewrite support with your administrator."

Do you see anything incorrect here? What have you changed .htaccess?

Thanks a lot for your help.

Lou

bonobo’s picture

in the .htaccess file related to the rewrite rules -- My multi-site setup worked with the standard .htaccess that comes with the drupal tarball.

I did a quick google search of the drupal site, and found some links that might be of use, but without knowing more about your hosting setup, I'm not sure where to look next.

Make a backup of your current .htaccess, then upload the standard .htaccess that comes with the drupal download. If that doesn't work, post some info about your hosting setup -- Apache version, PHP version, if PHP running as CGI, etc, and we'll go from there.

Hope this helps.

Cheers,

bonobo

-------
http://www.funnymonkey.com
Tools for Teachers

conbry’s picture

As you said, I commented out the following in .htaccess:
RewriteBase /
Then, clean urls works for site www.example.com/en. It is a little bit strange that I had to make the change to .htaccess to support clean urls for www.example.com.

I am very happy clean urls work now for both sites.

Thanks a lot for your help!

Lou

vuquochuy’s picture

I did the following instructions
http://drupal.org/node/25011#comment-136227

------------------------------
My Website: http://huyvq.com

philbar’s picture

I'm having a similar problem but the default .htaccess doesn't fix it as suggested in this thread.

I have Drupal 5.7 installed in www.example.com/drupal5. I do not want this to be visible to any users.

I have created a few symlinks to www.example.com/sub1, www.example.com/sub2 and each of those have their own site configuration.

The problem is that none of the .htaccess configurations I have tried work.

------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

and

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Results in a 404 error.

------
RewriteBase /drupal5
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

and

RewriteBase /sub1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Cause the site to be accessible from www.example.com, but not from the sub-directories.

What am I doing wrong?

rockefeller’s picture

Hi!

I want to implement Clean Urls function to work to the following case:

I have a main website called www.hiwz.org, the domain name is hosted in the server www.chistescool.com/hiwz

This means that when you enter hiwz.org you are really seeing chistescool.com/hiwz contents. The thing is that I have installed drupal in that subdirectory and Im able to enable Clean Url correctly at www.chistescool.com/hiwz. The problem is that when I enter www.hiwz.org and try to login to the drupal application, I have a 500 server error (when clean urls is enabled). Ive read different posts about making Clean Url work in a multisite, but most of them are in the same server (different drupal installs in main directory and subdirectory) or at least none of them has spoke about this type of issue.

I host my websites in godaddy, which allows to host other domain names in your same server. It is shared hosting and obviously mod-rewrite, etc are working because clean url can be enabled and works properly if you enter to the domain www.chistescool.com/hiwz

I want to make it work for www.hiwz.org , is it possible??

Thanks in advance for your help

rockefeller’s picture

The problem was that when I accesed to the addon domain I had a 500 Internal server error when I login through the addon domain or clicked in any other sections (like admin link) when clean url was active. As the addon domain points to a another domain with a subdirectory, What I needed to do was the following:

In the .htaccess file I had to change the following:

BEFORE
--------------------------------------------
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

AFTER (included full URL and it worked correctly from the main domain... it cannot be accesed through the other subdirectory though, still I did not needed that)
--------------------------------------------

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ http://www.example.com/index.php?q=$1 [L,QSA]

Hope it helps to others trying to do the same. Remember if you have a 500 internal server errors and addon domains involved, try this.

Good luck!

vood002’s picture

It doesn't seem like my RewriteBase problem has been covered anywhere else.

I'm running MAMP on my development server and I have two folders (drupal5 and drupal6) in the root public_html directory. Mod Rewrite is on, htaccess is enabled and I've tested it successfully.

To run multiple sites I have them set up in the hosts file ( ie: site1 127.0.0.1 ), then in the /sites/ directory I have a folder called "site1", this all works great...I am able to access these via http://site1:8888/drupal6. I don't think this part matters but I thought I would include it anyway, as this problem still occurs when using the default drupal site ( ie localhost:8888/drupal6/ )

The sites navigate fine as long as I change $base_url in the settings.php file to something like http://site1:8888/drupal6. But, any images and other files that are referenced in nodes don't work. Even when I change the htaccess file in the /drupal6/ directory to reflect something like RewriteBase /drupal6 images that are referenced relatively to the base directory (ie /files/site1/images/xxx.jpg) do not reflect any change. From what I understand if I add an image with a src of "/files/something" and have RewriteBase /drupal6 set then the image path should change to "/drupal6/files/something", right?

I'm a bit stumped about what this might be. Perhaps, although htaccess is working, rewritebase isn't for some reason? I have AllowOverride set to "all" in httpd.conf. Maybe I'm just going about the whole thing incorrectly? Any help would be appreciated.

----
http://www.johnpezzetti.com

vood002’s picture

Well apparently nobody knew the answer to the question I previously posed...to recap

RewriteBase /drupal wasnt working for me, even when combined with the $base_url variable in settings.php. All paths to pages would be correct, but paths to attached files and images were not correct (did not add the /drupal before /files/images/whatever).

I'm running two versions of drupal, 5 and 6, each is in a subdirectory of my public_html directory on my development server-- /drupal5 and /drupal6. I was able to modify some .htaccess code that I picked up previously to allow me to run drupal in a subdirectory. By naming sites in the sites folder as locald6.site.com or locald5.site.com depending upon their version of drupal, then adding these addresses to my .hosts file, I was able to get the server routing correctly using the following mod rewrite directives in my .htaccess file:

Options -Indexes
RewriteEngine on
Options +FollowSymLinks

#################################
### IF DRUPAL 6 (locald6.x) ###
#################################

RewriteCond %{HTTP_HOST} ^locald6.*
RewriteRule ^$ drupal6/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/drupal6%{REQUEST_URI} -f
RewriteRule .* drupal6/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*wiki.*
RewriteCond %{HTTP_HOST} ^locald6.*
RewriteRule .* drupal6/index.php?q=$0 [QSA]

#################################
### IF DRUPAL 5 (locald5.x) ###
#################################

RewriteCond %{HTTP_HOST} ^locald5.*
RewriteRule ^$ drupal5/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/drupal5%{REQUEST_URI} -f
RewriteRule .* drupal5/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*wiki.*
RewriteCond %{HTTP_HOST} ^locald6.*
RewriteRule .* drupal5/index.php?q=$0 [QSA]

----
http://www.johnpezzetti.com