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站点url的规则不起作用_.htaccess_Mod Rewrite_Redirect_Url Rewriting_Drupal 6 - Fatal编程技术网

.htaccess 重写drupal站点url的规则不起作用

.htaccess 重写drupal站点url的规则不起作用,.htaccess,mod-rewrite,redirect,url-rewriting,drupal-6,.htaccess,Mod Rewrite,Redirect,Url Rewriting,Drupal 6,我试图在.htaccess文件中为我的drupal站点编写一些重写规则,但它似乎根本不起作用。我之前对正则表达式和mod_重写缺乏知识和经验,这似乎也无助于解决问题 我试图重写的URL如下 资料来源: http://www.mydrupalsite.com/somealphanumericwithspecialchars/somealphanumericwithspecialchars/somealphanumericwithspecialchars/somealphanumericwithsp

我试图在.htaccess文件中为我的drupal站点编写一些重写规则,但它似乎根本不起作用。我之前对正则表达式和mod_重写缺乏知识和经验,这似乎也无助于解决问题

我试图重写的URL如下

资料来源:

http://www.mydrupalsite.com/somealphanumericwithspecialchars/somealphanumericwithspecialchars/somealphanumericwithspecialchars/somealphanumericwithspecialchars/Keyword1/Keyword2/UNIQUEID?queryparam1=somenumber

目的地:

http://www.mydrupalsite.com/legacystuff/UNIQUEID

我的.htaccess mod_重写代码是

  RewriteEngine on
  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  #This is the only rule written by me others are drupals
  RewriteRule ^(.*)/(.*)/(.*)/(.*)/Keyword1/Keyword2/([0-9]*)?$ legacystuff/content/$5 [R=302]
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
我基于快速浏览教程的理解和实现是前四个。*将与URL中的四个字母数字字符匹配,关键字1和关键字2将保持不变,因此我可以将它们匹配,目标中我的目标URL参数$5实际需要的唯一数字id将由[0-9*]捕获?。我在本地环境的httpd.conf中使用以下vhost

<VirtualHost *:80>
DocumentRoot "C:/wamp/www/mydrupalsite"
ServerName mydrupalsite.com
</VirtualHost>

我的问题是,在重新启动本地服务器并清除缓存后,从源URL重定向到目标URL不会发生。对于我在哪里出错以及如何纠正错误的任何帮助,我们都将不胜感激。

最终让它工作起来,为我的虚拟主机设置添加了RewriteBase,并将RewriteRule与尾部一起放在它下面?在我的目标中忽略查询字符串和L标志。在httpd.conf中设置RewriteLog有助于从更好的角度理解问题。希望这对drupal中的.htaccess新手有所帮助

RewriteBase /
RewriteRule ^(.*)/(.*)/(.*)/(.*)/Keyword1/Keyword2/([0-9]*)?$ legacystuff/content/$5? [R=301,L]  

[0-9*]?$已损坏,我想您指的是[0-9]*$,请确保RewriteEngine On位于其中一个配置文件中的某个位置。我将对此进行编辑,RewriteEngine肯定已打开。