Clean URLs

Som den väldigt observanta har märkt så använder jag från och med igår Clean URls funktionen i Drupal. Med Clean URLs får man bort den fula query-strängen som Drupal lägger till i URLen.
Så här gjorde jag:

Jag antar att du kör alla kommandon som superuser. (sudo su)
Jag kontrollerade först att mod_rewrite var laddad i apache.

apache2ctl -M

Om du ser rewrite_module i listan så är den laddad.

Om du inte ser rewrite_module i listan så måste du ladda den med detta kommando.

a2enmod rewrite

Om du använder virtual hosts så ska du göra en liten ändring i /etc/apache2/sites-available/SIDANS_NAMN
Sätt

AllowOverride None

...till...

AllowOverride All

...på alla ställen i filen.

Spara filen och starta om apache med följande kommando.

/etc/init.d/apache2 force-reload

Nu behöver du bara se till att .htaccess filen ligger i rooten på din Drupal-webbplats. Jag har hört att det kan vara ett problem med vissa FTP-program som ignorerar .htaccess filen.

Exempel på hur drupals .htaccess fil kan se ut.

#
# Apache/PHP/site settings:
#
# Protect files and directories from prying eyes:
< Files ~ "(\.(conf|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 server error messages:
ErrorDocument 404 /index.php
# Set the default handler to index.php:
DirectoryIndex index.php
# Overload PHP variables:
< IfModule sapi_apache2.c>
# If you are using Apache 2, you have to use
# instead of .
php_value register_globals 0
php_value track_vars 1
php_value short_open_tag 1
php_value magic_quotes_gpc 0
php_value magic_quotes_runtime 0
php_value magic_quotes_sybase 0
php_value arg_separator.output "&"
php_value session.cache_expire 200000
php_value session.gc_maxlifetime 200000
php_value session.cookie_lifetime 2000000
php_value session.auto_start 0
php_value session.save_handler user
php_value session.cache_limiter none
php_value allow_call_time_pass_reference On
< /IfModule>
# Various rewrite rules
< IfModule mod_rewrite.c>
RewriteEngine on
Options All
# Modify the RewriteBase if you are using Drupal in a subdirectory and the
# rewrite rules are not working properly:
RewriteBase /
#cron
# RewriteRule /cron\.php $0 [I,L]
# 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>
# $Id: .htaccess,v 1.58 2004/10/09 20:41:49 dries Exp $

Det borde nu fungera. Gå till Administer » Site configuration » Clean URLs. Där kan du nu välja enable.

Om det inte fungerar så testa ändra

RewriteBase /

till

RewriteBase /DinWebbplatsMapp

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <strong> <cite> <code> <b> <i>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.