0
<IfModule mod_rewrite.c>
  RewriteEngine On

</IfModule>

これは私のサーバー(mypage.com)の.htaccessファイルにあります。

どうすれば作成できますか:

  1. here.mypage.comを開くと、 mypage.com /here.htmlにリダイレクトされます
  2. mypage.com/nowを開くと、 mypage.com / now/test.htmlにリダイレクトされます。

私のページはPHPです。

4

4 に答える 4

2

1.here.mypage.comを開くと、mypage.com/here.htmlにリダイレクトされます

here.mypage.comがhtaccessファイルと同じドキュメントルートである限り、次を追加します。

RewriteCond %{HTTP_HOST} ^here\.mypage\.com$ [NC]
RewriteRule ^$ http://mypage.com/here.html [R=301,L]

2. mypage.com/nowを開くと、mypage.com / now/test.htmlにリダイレクトされます

追加:

RewriteCond %{HTTP_HOST} ^mypage\.com$ [NC]
RewriteRule ^now$ /now/test.html [L]
于 2012-08-09T12:09:34.577 に答える
1
RewriteEngine on
RewriteRule ^now$ now/test.html

それは2番目のものです。1つ目は、ウェブサイトのcPanel(または同様のもの)を使用して新しいサブドメインを作成し、サブドメインがメインのpublic_htmlフォルダーを指すようにする必要がありますが、正確なヘルプを提供するには、サーバーに関する詳細情報が必要になる可能性があります。

編集:

RewriteCond %{HTTP_HOST} ^here.mypage.com [NC] 
RewriteRule ^/here.html [L] 

これでサブドメインができます。

于 2012-08-09T12:08:24.407 に答える
1

here.mypage.comをmypage.com/here.htmlにリダイレクトするには、.htaccessにルールを追加するだけでは不十分です(=>サブドメインの設定を参照)。

もう1つは、次を追加できます。

RewriteRule ^now$ now/test.html
于 2012-08-09T12:09:54.017 に答える
0

これを試してみてください:

Redirect 301 here.mypage.com mypage.com/here.html
Redirect 301 mypage.com/now mypage.com/now/test.html
于 2012-08-09T12:07:40.680 に答える