Clean URL's on a sub domain and one-off's

opegasus's picture

I happened to mention this dilemma to a fellow Drupaler (she had actually coerced me into learning Drupal-my being a Joomla! person) about the inability to score a clean test to un-gray/unlock the Clean URL's option.

She asked a simple question (K.I.S.S.) "Do you have it as a domain or a sub-domain?" I replied "Sub-domain, why?" She went on to say this may be a case of one-off's. Instantly I knew what she was referring to. In one of my many classes for web certification it was stressed to insure one is aware and follows P.T.F. (Path To File) strictly (unless using relative paths) meaning Path To File

Long story short, I emailed tech support for the hosting company and stated the issue and what might be a one off situation. The answer came back, try this and let us know if it works. It did!

Okay so what was the problem and solution?

.htaccess needed to be rewritten so the Drupal files and database knew where everything was/is. On a sub-domain the .htacess needs to be pointed properly. Let me just put the reply in here so you can follow along. I changed some of the P.T.F. names so simply put your site information in it's place for clearer understanding

I see the following error in /logs/error_log
for the account:

Aug 24 12:43:44 [error] [client XX.XXX.XXX.XX] File does not exist:
/domains/d/yoursite.com/htdocs/dev/domains/d/yoursite.com/htdocs/dev/puppydogs/index.php

So modifying the RewriteBase sounds like a smart move, as you can see
the 'nested' file paths occurring in the error.

The file /htdocs/dev/puppydogs/.htaccess includes the following:

RewriteEngine on

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

So, you may modify the RewriteBase directive so it looks like:

RewriteEngine on

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

Let us know if that helps.

Uh yeah, it worked like a charm

. Just to be sure after I 'put' the rewritten .htaccess file I cleared the cash, ran a manual cron job and then went back to the Clean URL's module and the auto test (Drupal 6-x) came through clean as a whistle. I get to remember (write it down!) that when the site is moved to it's production place to rewrite the .htaccess.

If I were keeping the site where it is parked (just there for DEV right now) I would leave the .htaccess file as is.

I hope this helps others who slam to a stop on this issue like I did. Beware the One Off's! (being one off on pointing to the correct level).

Comments

Lighttpd Clean url for a drupal site

karthick62's picture

Hi,

I am trying to write a clean url of my site. This is the structure of the site

www.example.com
www.example.com/site1
www.example.come/site2
;
;
; www.example.com/siten

site1 ... siten are installed as subdirectories. I tried the following clean url for subdirectory and the main site.

  1. For subdirectory (www.example.com/site1) => "^/([^/])/(?!(misc|themes|modules|files|test|system|sites|.xml|.html|.css|.js))([^?])\??(.*)$" => "/$1/index.php?q=$3&$4" (Tested OK for subdir)

  2. For Main site (www.example.com) => "^/([^.?]*(.xml|.html)?)(\?(.+))?$" => "/index.php?q=$1&$4" (Tested Ok for main site)

I have been facing problems if I use both(main site and subdirectory) clean url rewrite rules under same url.rewrite in lighttpd.conf

Issue 1:

The rewrite url for the subdirectory is working fine and I am able to access all the pages but no pages in the main site.

Issue2:

If I test the main site with the clean url () alone in the rewrite rule, the pages for the main site are getting properly.

Can anyone help in sorting out this issue?

I would need a rewrite url which should satisfy the clean url conditions of both mainsite and subdirectory.