0

次の .htaccess コードを使用しています。

ルートフォルダーの .htaccess

#for redirecting www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule (.*) http://%1/$1 [R=301,L]

#temporary redirect root to dir/
RedirectMatch ^/$ /dir/

dir フォルダー内の .htaccess

RewriteEngine  on
#for changing index file to a custom one
DirectoryIndex abc.php?tag=ho

#for simple url
RewriteRule ^what/([^/]*)\.html$ /dir/abc.php?tag=$1 [L]

現在のコードでは、www.domain.com は domain.com にリダイレクトされますが、www.domain.com/dir/ はリダイレクトされません。

次の 2 点を修正する必要があります。

  1. www を非 wwww にリダイレクトする
  2. domain.com を domain.com/dir/ にリダイレクトします

よろしくお願いします。

4

1 に答える 1

1

Redirect(match) と rewriterule を組み合わせると問題が発生します。RedirectMatch の代わりに次を使用します。

RewriteCond $1 !^dir/
RewriteRule ^(.*)$ /dir/$1 [R=301,L]
于 2012-05-25T19:16:19.197 に答える