3

I have spent about four hours trying to get clean URLs to work and it is really doing my head in. I am very new to Drupal and after hearing all the wonderful things about it, this is disappointing. Here is my setup:

I have XAMPP on windows 7, and installed Drupal 7.22 into a folder c:\code\drupal

In my httpd.conf, I have Alias /code "C:\code" This works because I have other folders inside c:\code functioning perfectly well

The drupal .htaccess file works because if I add junk line in there I get a server error

In the .htaccess I tried all combinations of RewriteBase I could think of:

RewriteBase /
RewriteBase /code
RewriteBase /code/drupal
RewriteBase /drupal

mod_rewrite works because I already have other installations which uses it correctly.

I also tried going directly to http://localhost/code/drupal/admin/config/search/clean-urls but that gives me a 404 error

Every time I go back to admin > config > clean URLS, it says the test failed. I know this is apparently some error from my side, but its getting very frustrating. Can anyone see what I am missing here? :(

  • I read all the similar questions here in SO, but their solutions do not work for me.
  • I posted this in drupal.stackexchange.com as well but did not get any answers.
  • I am posting it here since the SO PHP community is more active and undoubtedly there are many who know drupal in depth.
  • I am really hoping someone will help me figure this out...
Undefined Variable
  • 4,196
  • 10
  • 40
  • 69
  • If you look at the error log where the petition for that host is displayed, is the URL being rewritten? Or is it asking for the url without giving it the rewrite rule? – Chayemor May 16 '13 at 19:09
  • It is going without rewrite rule. It hits the drupal page with regular URL and a gives 200 response. The regular URL gives a message saying rewrite cannot be enabled. The online docs suggested all the stuff that I tried above in my question - but to no avail. And the entry is in access.log not error.log since there are no errors per se.. – Undefined Variable May 16 '13 at 19:18
  • Try to replace entire .htaccess with something pretty simple like `RewriteEngine on RewriteBase / RewriteRule ^.*$ http://google.com` Is it redirecting you to google.com? Also you can try to write log files for rewrite module, just add to your httpd.conf file following: `RewriteLog "/home/rewrite.log" RewriteLogLevel 9` Maybe there will be something interesting in logs :) – tulvit May 16 '13 at 19:44
  • @tulvit: Thanks for the suggestions. 1) Yes, it redirects to google.com. 2) I added line to httpd.conf, restarted server and tried accessing urls, but the file rewrite.log is not getting created. error.log does not say anything about it either... – Undefined Variable May 16 '13 at 20:05
  • Actually - I was wrong, it is creating rewrite.log (I gave nonexistant file path). Let me check that and get back in a few! Thanks heaps, you rock!!! – Undefined Variable May 16 '13 at 20:11
  • Rather strange... Last time I have problems with mode rewrite in Drupal `RewriteBase /` did the trick, but you've already tried it( I hope you change `"/home/rewrite.log"` to the real path (it should be something like C:/logs in Windows, I guess), if so I have no clue why log file have not been created. /Oh, you've already changed path! =) By the way, this logs didn't help me a lot last time I've used them, but I hope it'll be quite helpful in your case =) – tulvit May 16 '13 at 20:11
  • Yeah, the log gets created but not much help. When I go to localhost/code/drupal - it makes entry about all the rewrites and the page also gets loaded, but when I go to any other page with clean URL and get a 404, the rewrite log does not say anything. Oh well....I am not sure if Drupal & I are going to get along... :) – Undefined Variable May 16 '13 at 20:16
  • Just have find this article [Clean URLs with XAMPP](http://drupal.org/node/43545), but I guess you've already read it. And according to [this answer](http://stackoverflow.com/questions/12272731/using-mod-rewrite-with-xampp-and-windows-7-64-bit/12273060#12273060) maybe `RewriteBase /drupal/` will work (with additional slash). – tulvit May 16 '13 at 20:30

1 Answers1

2

I don't know if you still need help, but I spent good amount of time trying to figure that out myself a while ago and couldn't find the right answer. After doing a lot of trial and error, I made it work. I don't know exactly how your setup is but here is how mine is, as well as my solution on drupal.org.

(Here is a copy of a part of my original question and my complete solution)

Hi,

I have a Drupal multisite setup and I am trying to make the Clean URLs work but cannot seem to be able to write the conditions and rules properly. I have found many answers but none of them worked.

My .htaccess file is being read without problem and the rules are being used (I tried setting the rewrite rule to the full address but it was only giving me the home page and I couldn't go anywhere else).

Here is how it is setup:

DEV: URL1 www.site1.domain.fr/dev
         URL2 www.site2.site1.domain.fr/dev

PROD URL1 www.site1.domain.fr
           URL2 www.site2.site1.domain.fr

On the server: /dev (one drupal install)
                       /prod (another drupal install but same content)

My multisite is setup as this:
/sites/site1.domain.fr
/sites/site2.site1.domain.fr (same thing for dev and for prod)

Inside sites.php:

$sites = array( 
 'www.site1.domain.fr' => 'site1.domain.fr', 
 'www.site2.site1.domain.fr' => 'site2.site1.domain.fr', )


Solution

I was finally able to fix it by trial and error. In case any of you encounter the same problem, here is how I fixed it:

DEV: 

RewriteBase /dev

# Main site 
RewriteCond %{HTTP_HOST} ^site1\.domain\.fr [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ site1.domain.fr/dev/index.php?q=$1 [L,QSA]

# Site 2 
RewriteCond %{HTTP_HOST} ^site2.site1\.domain\.fr [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ site2.site1.domain.fr/dev/index.php?q=$1 [L,QSA]


PROD: 

RewriteBase /

# Main site 
RewriteCond %{HTTP_HOST} ^site1\.domain\.fr [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ site1.domain.fr/index.php?q=$1 [L,QSA]

# Site 2 
RewriteCond %{HTTP_HOST} ^site2.site1\.domain\.fr [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ site2.site1.domain.fr/index.php?q=$1 [L,QSA]
Casey B
  • 66
  • 6