0

我是 mod_rewrite 的新手,到目前为止一直在反复试验,我想将所有 URL 请求重定向到 /drupal-6.13/ 并隐藏 /drupal-6.13/,但如果 URL 是 www.site .com/wiki 不要重写任何东西。我还在 drupal 中使用 pathauto mod 为故事内容创建 /content/title 链接。我认为这是重写 URL 的顶部和底部 htaccess 中的最后一部分,因为 www.iamthelaw.net/wiki 被重写为http://www.iamthelaw.net/wiki/?q=wiki,但是如果我尝试删除他们的管理链接和内容链接不再起作用。有什么我可以添加的,而无需删除当前仅用于 /wiki/ 请求的内容吗?

这是顶层的 htacess:

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>
4

4 回答 4

0

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

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

于 2009-09-08T07:59:15.870 回答
0

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

于 2009-09-07T23:03:14.257 回答
0

正如我认为 Dav 所说,您/wiki首先制定规则,[L]因此忽略/wiki. 其次是你的其他规则

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

我希望你能适应你的情况

于 2009-09-07T23:48:45.023 回答
0

我已经在本地尝试过,它似乎有效。它适用于您的根 .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 文件中 RewriteBase,因为所有 url 都已被重定向到该文件夹​​。

于 2009-09-11T03:08:54.630 回答