.htaccess - Drupal 7 RewriteRule not working -


my basic page access i.e : mysite/aboutus, working fine.

but due request, every page except home needs prefixed training.

so if need go mysite/aboutus, instead need go mysite/training/aboutus.

i edited every page needed rewriting mypage.tpl.php, change path troublesome.

i tried edited .htaccess in project folder, below of attempts :

rewriterule ^/training/about$ /about rewriterule ^(.*)/training/about$ $1/about 

none works.

could point me right direction?

cheers !

    # # apache/php/drupal settings: #  # protect files , directories prying eyes. <filesmatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|themes|tpl(\.php)?|xtmpl)$|^(\..*|entries.*|repository|root|tag|template)$">   order allow,deny </filesmatch>  # 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    # 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 /drupal   #   # 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> 

the following works drupal 7

rewriterule ^home/code/([^/]+) ?q=home/software/node/&code=$1 

make sure exclude condition before rewriterule ^ index.php [l]

rewritecond %{request_uri} !yourcustomrewriterulecondition rewriterule ^ index.php [l] 

see here: https://drupal.stackexchange.com/questions/55006/rewrite-url-not-working/94372#94372


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -