Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 25th April 2005, 12:46
andre andre is offline
Junior Member
 
Join Date: Apr 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
Sponsored Links
  #2  
Old 25th April 2005, 20:11
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,900
Thanked 2,702 Times in 2,545 Posts
Default

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!)
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 26th April 2005, 10:39
uli uli is offline
Junior Member
 
Join Date: Apr 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #4  
Old 26th April 2005, 14:48
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,900
Thanked 2,702 Times in 2,545 Posts
Default

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.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 19th November 2005, 01:12
timbo timbo is offline
Junior Member
 
Join Date: Nov 2005
Location: Texas, US
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
Default 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>

Last edited by timbo; 19th November 2005 at 01:16.
Reply With Quote
  #6  
Old 19th November 2005, 01:15
timbo timbo is offline
Junior Member
 
Join Date: Nov 2005
Location: Texas, US
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
Default

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.
Reply With Quote
  #7  
Old 19th November 2005, 03:15
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,900
Thanked 2,702 Times in 2,545 Posts
Default

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.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #8  
Old 19th November 2005, 04:27
timbo timbo is offline
Junior Member
 
Join Date: Nov 2005
Location: Texas, US
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
Talking 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
Reply With Quote
  #9  
Old 4th May 2006, 20:26
stamy stamy is offline
Junior Member
 
Join Date: May 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy

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... ?)
Reply With Quote
  #10  
Old 4th May 2006, 21:04
stamy stamy is offline
Junior Member
 
Join Date: May 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The solution is here:

http://www.howtoforge.com/forums/sho...4957#post24957
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 20:17.


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