在Drupal中重定向index.php和htaccess中的home

在Drupal中重定向index.php和htaccess中的home,drupal,.htaccess,redirect,drupal-6,Drupal,.htaccess,Redirect,Drupal 6,我一直在尝试为/home和/index.php创建指向站点基本url的重定向。我在htaccess中尝试过遵循规则,但没有任何效果 RewriteRule ^(.*)\index.php$ $1 [R=301,L] RewriteRule ^home$ / 我是新来的,如果这对专家来说是个微不足道的问题,那么请宽容我 提前感谢这里热心帮助的好心人。这行不通。对不存在的文件和目录(如/node/42)的所有请求实际上都被重定向到/index.php(如/index.php?q=node/42)

我一直在尝试为/home和/index.php创建指向站点基本url的重定向。我在htaccess中尝试过遵循规则,但没有任何效果

RewriteRule ^(.*)\index.php$ $1 [R=301,L]
RewriteRule ^home$ / 
我是新来的,如果这对专家来说是个微不足道的问题,那么请宽容我


提前感谢这里热心帮助的好心人。

这行不通。对不存在的文件和目录(如/node/42)的所有请求实际上都被重定向到/index.php(如/index.php?q=node/42)。如果您试图从index.php重定向,整个机制将崩溃。

这将不起作用。对不存在的文件和目录(如/node/42)的所有请求实际上都被重定向到/index.php(如/index.php?q=node/42)。如果您试图从index.php重定向,整个机制都会崩溃。

您应该能够使用Drupal和htacess实现这一点

htacess允许内部和外部重写

下面的代码将301将任何到root index.php页面的请求重定向到您的web根目录。您应该将这些规则放在Drupal的htacess内部重写规则之前,htacess内部重写规则基本上将所有内容指向index.php:

#Redirect requests to index.php to / (Added for SEO URL canonicalisation)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ / [R=301,L] 

#Drupals internal rewrite rules:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

您应该能够使用Drupal和htacess来实现这一点

htacess允许内部和外部重写

下面的代码将301将任何到root index.php页面的请求重定向到您的web根目录。您应该将这些规则放在Drupal的htacess内部重写规则之前,htacess内部重写规则基本上将所有内容指向index.php:

#Redirect requests to index.php to / (Added for SEO URL canonicalisation)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ / [R=301,L] 

#Drupals internal rewrite rules:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

那么你到底想实现什么呢?我想把www.site.com/home和www.site.com/index.php重定向到www.site.com那么你到底想实现什么呢?我想把www.site.com/home和www.site.com/index.php重定向到www.site.com