Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess Drupal 301重定向_.htaccess_Redirect_Drupal_Http Status Code 301 - Fatal编程技术网

.htaccess Drupal 301重定向

.htaccess Drupal 301重定向,.htaccess,redirect,drupal,http-status-code-301,.htaccess,Redirect,Drupal,Http Status Code 301,我正在Drupal中执行一组301重定向 我在.htaccess文件中使用标准方法: <IfModule mod_rewrite.c> RewriteEngine on Redirect 301 /user/testimonials http://thesitedomain.com/testimonials Redirect 301 /user/contact http://thesitedomain.com/contact </IfModule> 显然,我不擅长ht

我正在Drupal中执行一组301重定向

我在.htaccess文件中使用标准方法:

<IfModule mod_rewrite.c>
RewriteEngine on

Redirect 301 /user/testimonials http://thesitedomain.com/testimonials
Redirect 301 /user/contact http://thesitedomain.com/contact
</IfModule>
显然,我不擅长htaccess重定向,我根本不是Drupal专家


另外,如果您知道全面的htaccess重写资源,我将非常感谢阅读hat。

我无法与drupal交谈,但我知道您不需要将这些重定向包含在标记中,因为它们不使用重写引擎,以下内容就够了:

Redirect 301 /user/testimonials http://thesitedomain.com/testimonials
Redirect 301 /user/contact http://thesitedomain.com/contact
您需要使用mod_rewrite来删除现有的查询字符串:

RewriteEngine On

RewriteRule ^user/testimonials/?$ http://thesitedomain.com/testimonials? [L,NC,R=301] 
RewriteRule ^user/contact/?$ http://thesitedomain.com/contact? [L,NC,R=301] 

注意尾随?删除现有查询字符串的目标中。

两个URL在同一drupal中吗?或者你是从另一个地方搬来的? 我的意思是:

/用户/证明 也许您需要为/user/essentials(如/essentials)添加url别名


请参阅drupal 7中的admin下的/admin/config/search/path。

使用.htaccess文件不是一种好的做法,因为在某些更新中,您也必须更新.htaccess文件


您可以尝试使用模块来管理重定向。

不幸无法正常工作。。。它只会转到同一页:/user/commentials/确保此301规则是root.htaccess中的第一条规则,然后在新浏览器中进行测试。
RewriteEngine On

RewriteRule ^user/testimonials/?$ http://thesitedomain.com/testimonials? [L,NC,R=301] 
RewriteRule ^user/contact/?$ http://thesitedomain.com/contact? [L,NC,R=301]