简体   繁体   中英

Using htaccess how to check if request is Drupal's Front Page?

I am trying to configure Drupal 7 main .htaccess file, and after checking certain conditions(RewriteCond) in the .htaccess I need to check one more condition(RewriteCond); that if the request is for Drupal Front Page.
And if request is for the front-page redirect it to somewhere say, 'newfrontpage' an existing page.

What I tried:

RewriteCond %{REQUEST_URI} ^/index\.php$ #line1
RewriteRule ^(.*)$ http://example.com/newfrontpage [L,NC] #line2

Other options I have tried with #line1 are:

RewriteCond %{REQUEST_URI} ^$
RewriteCond %{REQUEST_URI} ^/node$

Nothing is working.
Other way around could be hook_process_page(&$variables) and check if($variables['is_front']).. but I think .htaccess would be more optimized!

Why don't you just set the Frontpage within Drupal's settings? Just go to Configure -> System -> Website-Information ( admin/config/system/site-information ) and set the path to your default frontpage there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM