Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.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
Mod rewrite mod_rewrite重定向除/wiki之外的所有URL_Mod Rewrite_Drupal_Mediawiki - Fatal编程技术网

Mod rewrite mod_rewrite重定向除/wiki之外的所有URL

Mod rewrite mod_rewrite重定向除/wiki之外的所有URL,mod-rewrite,drupal,mediawiki,Mod Rewrite,Drupal,Mediawiki,我是mod_rewrite的新手,到目前为止,我一直在尝试错误,我想将所有URL请求重定向到/drupal-6.13/并隐藏/drupal-6.13/,但如果URL是www.site.com/wiki,则不重写任何内容。我还在drupal中使用pathauto模块为故事内容创建/content/title链接。我认为这是htaccess顶部和底部重写url的最后一部分,因为www.iamthelaw.net/wiki被重写为,但如果我尝试删除它们,管理链接和内容链接将不再工作。我是否可以添加任何

我是mod_rewrite的新手,到目前为止,我一直在尝试错误,我想将所有URL请求重定向到/drupal-6.13/并隐藏/drupal-6.13/,但如果URL是www.site.com/wiki,则不重写任何内容。我还在drupal中使用pathauto模块为故事内容创建/content/title链接。我认为这是htaccess顶部和底部重写url的最后一部分,因为www.iamthelaw.net/wiki被重写为,但如果我尝试删除它们,管理链接和内容链接将不再工作。我是否可以添加任何内容,而不需要删除当前存在的内容,以便仅为/wiki/请求覆盖这些内容

以下是顶层的Htaces:

Options -Indexes
RewriteEngine on
Options +FollowSymLinks

#site
RewriteCond %{HTTP_HOST} ^www\.iamthelaw\.net$ [NC]
RewriteCond %{REQUEST_URI} !^/drupal-6.13
RewriteRule ^$ /drupal-6.13/index.php [L]


#files
RewriteCond %{HTTP_HOST} ^www\.iamthelaw\.net$ [NC]
RewriteCond %{REQUEST_URI} ^.*\.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_URI} !^/drupal-6.13/
RewriteRule ^(.*)$ /drupal-6.13/$1 [L,QSA]

#url 's
RewriteCond %{HTTP_HOST} ^www\.iamthelaw\.net$ [NC]
RewriteCond %{REQUEST_URI} !^/drupal-6.13
RewriteRule ^(.*)$ /drupal-6.13/index.php?q=$1 [L,QSA]
在子文件夹/drupal-6.13/的htacess的重写部分:

# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on

RewriteBase /drupal-6.13


# 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
RewriteRule ^(.*)$ /drupal-6.13/index.php?q=$1 [L,QSA]
</IfModule>

将/wiki的重写规则放在文件的前面,并确保它有一个L作为修饰符的一部分,最有可能是[L,QSA],这样它是为匹配URL处理的最后一个规则,因此以后的重写不会影响它。

正如我认为Dav所说的,您首先为/wiki制定了一个规则,使用[L]可以忽略/wiki的进一步规则。遵循您对其他suff的规则

RewriteRule ^wiki /wiki  [L]
RewriteRule ^.* /notwiki

我希望你能根据自己的情况调整这一点

我认为你只需要两条规则:

RewriteCond %{THE_REQUEST} ^GET\ /drupal-6\.13
RewriteRule ^drupal-6\.13($|/.*) 
RewriteRule !^wiki($|/) drupal-6.13/index.php [L]

这些命令从任何请求中删除/drupal-6.13,即URL路径以/drupal-6.13/开头,并重写任何请求,即URL路径不以/wiki/开头,在内部为/drupal-6.13/index.php。

我在本地尝试过这个方法,它似乎可以工作。它适用于您的root.htaccess文件:


RewriteEngine on

# Leave the wiki calls alone
RewriteCond %{REQUEST_URI} ^wiki.*$
RewriteRule ^.*$ - [L]

# redirect everything else to the drupal directory. 
# the drupal .htaccess takes care of drupal-specific rewrites 
RewriteRule ^(.*)$ drupal-6.13/$1 [L]

和。。我认为您也不需要在drupal.htaccess文件中重写base,因为所有URL都已被重定向到该文件夹。

感谢您的帮助,我尝试添加:wiki RewriteCond%{HTTP\u HOST}^www\.iamthelaw\.net\wiki$[NC]RewriteCond%{REQUEST\u URI}^/wiki RewriteRule^.*$/wiki[L,QSA]位于第一个htaccess的顶部,第二个htaccess位于RewriteBase的上方,但我仍然将www.iamthelaw.net/wiki重定向到