HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Server Operation (http://www.howtoforge.com/forums/forumdisplay.php?f=5)
-   -   Drupal and Apache Rewrite Rules (http://www.howtoforge.com/forums/showthread.php?t=38)

andre 25th April 2005 12:46

Drupal and Apache Rewrite Rules
 
Hi,

I've set up a Drupal-based web site. Drupal is right in the web server's document root. Now Drupal can generate search-engine friendly URLs (www.domain.com/a/b/c instead of www.domain.com/index.php?1=a&2=b&3=c), but to use this feature I have to create a .htaccess file with Apache rewrite rules in the document root.
Drupal comes with a sample .htaccess file, but it's not working. The rewrite rules look like this:

Code:

# Various rewrite rules
<IfModule mod_rewrite.c>
 RewriteEngine on

  # Modify the RewriteBase if you are using Drupal in a subdirectory and the
  # rewrite rules are not working properly:
  #RewriteBase /drupal

  # Rewrite old-style URLS of the form 'node.php?id=x':
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^id=([^&]+)$
  #RewriteRule node.php index.php?q=node/view/%1 [L]

  # Rewrite old-style URLs of the form 'module.php?mod=x':
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
  #RewriteRule module.php index.php?q=%1 [L]

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

What's wrong here?

Andre

falko 25th April 2005 20:11

Try this:

Code:

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
</IfModule>

(Note the / in front of index.php!)

uli 26th April 2005 10:39

I have the same problem, but my Drupal is not in the document root, but in the subdirectory drupal. Does it make a difference (because falko's solution doesn't work for me...)?

Uli

falko 26th April 2005 14:48

Code:

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteBase /drupal/
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

might work.

timbo 19th November 2005 01:12

Clean URLs for Drupal??
 
Hi,

I am also trying desperately to enable Clean URLs for my drupal installation.

I have a fresh installation of ISPConfig 2.1.1 and have my drupal installation in /var/www/web1 (www.10thdimens10n.com).

I have tried editing the .htaccess file according to above, however this only results in a 500 internal server error.

The drupal documentation for clean urls is here. http://drupal.org/node/15365 Could someone perhaps have a look?

in addition:

the output of /var/www/web1/.htaccess:
Code:

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<Files ~ "(\.(inc|module|pl|sh|sql|theme|engine|xtmpl)|Entries|Repositories|Root|scripts|updates)$">
  Order deny,allow
  Deny from all
</Files>

# Set some options.
Options -Indexes
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More exist in sites/default/settings.php, but
# the following cannot be changed at runtime. The first IfModule is
# for Apache 1.3, the second for Apache 2.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

# Reduce the time dynamically generated pages are cache-able.
<IfModule mod_expires.c>
  ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
 RewriteEngine on


  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # the rewrite rules are not working properly.
  # RewriteBase /var/www/web1

  # Rewrite old-style URLs of the form 'node.php?id=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^id=([^&]+)$
  RewriteRule node.php index.php?q=node/view/%1 [L]

  # Rewrite old-style URLs of the form 'module.php?mod=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
  RewriteRule module.php index.php?q=%1 [L]

  # 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]
</IfModule>


timbo 19th November 2005 01:15

My apache2.conf file is too long to post here. let me know if and what part you might need to look at if any.

Thanks a truckload in advance. You guys rock.

falko 19th November 2005 03:15

Quote:

Originally Posted by timbo
the output of /var/www/web1/.htaccess:

You are in the wrong folder. The correct folder to install Drupal is /var/www/web1/web.

timbo 19th November 2005 04:19

Okay. Now I'm totally confused. Why is everything which is installed into the /var/www/web1/web folder mirrored into /var/www/web1?

When I move the file .htaccess from /var/www/web1 into /var/www/web1/web and point to my site, the server returns a 500 internal error. When I take it out out, the site works. What gives?

What is in that drupal .htaccess file that disagrees with my LAMP setup? :confused:

timbo 19th November 2005 04:27

Got it!
 
I see now. I CREATED the .htaccess file using the code here:

Quote:

Originally Posted by falko
Try this:

Code:

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
</IfModule>

(Note the / in front of index.php!)

I thought you were telling him to add that to his existing .htaccess file.
My clean urls are working! Thanks!

tb

stamy 4th May 2006 20:26

Hello, i have a big trouble to install drupal 4.7 (the latest one) on ISPConfig 2.2.1 on a Debian Sarge.

I get an 500 internal error when i put this f****** .htacces file in my root directory: /var/www/web1/web/.htacces

I have modified the .htacces file (putting a slash before index.php ...like Falko's previous post)
I have installed drupal directly under /var/www/web1/web (no sub-directoy).

Here is my log file: (under web1/log/error.log)

[Thu May 04 20:03:59 2006] [alert] [client 82.231.213.145] /var/www/web1/web/.htaccess: Options not allowed here
[Thu May 04 20:03:59 2006] [alert] [client 82.231.213.145] /var/www/web1/web/.htaccess: Options not allowed here
[Thu May 04 20:04:00 2006] [alert] [client 82.231.213.145] /var/www/web1/web/.htaccess: Options not allowed here
[Thu May 04 20:04:00 2006] [alert] [client 82.231.213.145] /var/www/web1/web/.htaccess: Options not allowed here
[Thu May 04 20:04:58 2006] [alert] [client 82.231.213.145] /var/www/web1/web/.htaccess: Options not allowed here
[Thu May 04 20:04:58 2006] [alert] [client 82.231.213.145] /var/www/web1/web/.htaccess: Options not allowed here
[Thu May 04 20:04:58 2006] [alert] [client 82.231.213.145] /var/www/web1/web/.htaccess: Options not allowed here
[Thu May 04 20:04:58 2006] [alert] [client 82.231.213.145] /var/www/web1/web/.htaccess: Options not allowed here
[Thu May 04 20:04:59 2006] [alert] [client 82.231.213.145] /var/www/web1/web/.htaccess: Options not allowed here
[Thu May 04 20:04:59 2006] [alert] [client 82.231.213.145] /var/www/web1/web/.htaccess: Options not allowed here

Thank's for your help !
I guess these is a option like AllowOverride All but i dont known where to put it (maybe in /etc/apache2... ?)


All times are GMT +2. The time now is 13:38.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.