linux - clean URL in Drupal7 doesn't work -
i'm trying enable clean url on server (debian squezze) drupal website . tried of things found on net . please me .
the rewrite module enabled.
on server , drupal's folders got way : " /var/www/myshop/client/101b". symbolic link named "current" . access brower on website have write url : "http://myshop.myserv.com"
here .htaccess @ root of folder "101b":
# # apache/php/drupal settings: # # protect files , directories prying eyes. <filesmatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|entries.*|repository|root|tag|template)$"> order allow,deny </filesmatch> # don't show directory listings urls map directory. options -indexes # follow symbolic links in directory. options +followsymlinks # make drupal handle 404 errors. errordocument 404 /index.php # set default handler. directoryindex index.php index.html index.htm # override php settings cannot changed @ runtime. see # sites/default/default.settings.php , drupal_environment_initialize() in # includes/bootstrap.inc settings can changed @ runtime. # php 5, apache 1 , 2. <ifmodule mod_php5.c> php_flag magic_quotes_gpc off php_flag magic_quotes_sybase off php_flag register_globals off php_flag session.auto_start off php_value mbstring.http_input pass php_value mbstring.http_output pass php_flag mbstring.encoding_translation off </ifmodule> # requires mod_expires enabled. <ifmodule mod_expires.c> # enable expirations. expiresactive on # cache files 2 weeks after access (a). expiresdefault a1209600 <filesmatch \.php$> # not allow php scripts cached unless explicitly send cache # headers themselves. otherwise scripts have overwrite # headers set mod_expires if want caching behavior. may # fail if error occurs in bootstrap process, , may cause # problems if non-drupal php file installed in subdirectory. expiresactive off </filesmatch> </ifmodule> # various rewrite rules. <ifmodule mod_rewrite.c> rewriteengine on options # block access "hidden" directories names begin period. # includes directories used version control systems such subversion or # git store control files. files names begin period, # control files used cvs, protected filesmatch directive # above. # # note: works when mod_rewrite loaded. without mod_rewrite, # not possible block access entire directories .htaccess, because # <directorymatch> not allowed here. # # if not have mod_rewrite installed, should remove these # directories webroot or otherwise protect them being # downloaded. rewriterule "(^|/)\." - [f] # if site can accessed both , without 'www.' prefix, # can use 1 of following settings redirect users preferred # url, either or without 'www.' prefix. choose 1 option: # # redirect users access site 'www.' prefix, # (http://example.com/... redirected http://www.example.com/...) # uncomment following: # rewritecond %{http_host} !^www\. [nc] # rewriterule ^ http://www.%{http_host}%{request_uri} [l,r=301] # # redirect users access site without 'www.' prefix, # (http://www.example.com/... redirected http://example.com/...) # uncomment following: # rewritecond %{http_host} ^www\.(.+)$ [nc] # rewriterule ^ http://%1%{request_uri} [l,r=301] # modify rewritebase if using drupal in subdirectory or in # virtualdocumentroot , rewrite rules not working properly. # example if site @ http://example.com/drupal uncomment , # modify following line: rewritebase /myshop/client/101b # # if site running in virtualdocumentroot @ http://example.com/, # uncomment following line: # rewritebase / # pass requests not referring directly files in filesystem # index.php. clean urls handled in drupal_environment_initialize(). rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !=/favicon.ico rewriterule ^ index.php [l] # rules correctly serve gzip compressed css , js files. # requires both mod_rewrite , mod_headers enabled. <ifmodule mod_headers.c> # serve gzip compressed css files if exist , client accepts gzip. rewritecond %{http:accept-encoding} gzip rewritecond %{request_filename}\.gz -s rewriterule ^(.*)\.css $1\.css\.gz [qsa] # serve gzip compressed js files if exist , client accepts gzip. rewritecond %{http:accept-encoding} gzip rewritecond %{request_filename}\.gz -s rewriterule ^(.*)\.js $1\.js\.gz [qsa] # serve correct content types, , prevent mod_deflate double gzip. rewriterule \.css\.gz$ - [t=text/css,e=no-gzip:1] rewriterule \.js\.gz$ - [t=text/javascript,e=no-gzip:1] <filesmatch "(\.js\.gz|\.css\.gz)$"> # serve correct encoding type. header set content-encoding gzip # force proxies cache gzipped & non-gzipped css/js files separately. header append vary accept-encoding </filesmatch> </ifmodule> </ifmodule> and here 000-default file in "etc/apache2/site-enabled/ : "
<virtualhost *:80> serveradmin webmaster@localhost documentroot /var/www/myshop/client/current <directory /> options followsymlinks allowoverride </directory> <directory /var/www/myshop/client/current/> options indexes followsymlinks multiviews allowoverride </directory> alias /admin/ /var/www/myshop/backoffice/current/ <directory /var/www/myshop/backoffice/current/> options indexes followsymlinks multiviews allowoverride none order allow,deny allow </directory> scriptalias /cgi-bin/ /usr/lib/cgi-bin/ <directory "/usr/lib/cgi-bin"> allowoverride none options +execcgi -multiviews +symlinksifownermatch order allow,deny allow </directory> errorlog ${apache_log_dir}/error.log # possible values include: debug, info, notice, warn, error, crit, # alert, emerg. loglevel warn customlog ${apache_log_dir}/access.log combined </virtualhost> but when want enable clean url test fail. have idea ?
thanks .
you should use 'rewritebase /' instead of 'rewritebase /myshop/client/101b' because virtual host pointing folder contains drupal site.
please check version of apache you're using. newest versions of apache web-server require changes in host's definition. should use 'require granted' instead of 'allow all'. see example works me:
<virtualhost *:80> servername drupal7 serveralias drupal7 www.drupal7 documentroot /home/vlad/www/public_html/drupal7 <directory /home/vlad/www/public_html/drupal7/> options followsymlinks allowoverride require granted </directory> </virtualhost> please take @ answers here: unable enable clean urls in drupal 7 website after migration
Comments
Post a Comment