<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
これは私のサーバー(mypage.com)の.htaccessファイルにあります。
どうすれば作成できますか:
- here.mypage.comを開くと、 mypage.com /here.htmlにリダイレクトされます
- mypage.com/nowを開くと、 mypage.com / now/test.htmlにリダイレクトされます。
私のページはPHPです。
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
これは私のサーバー(mypage.com)の.htaccessファイルにあります。
どうすれば作成できますか:
私のページはPHPです。
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]
RewriteEngine on
RewriteRule ^now$ now/test.html
それは2番目のものです。1つ目は、ウェブサイトのcPanel(または同様のもの)を使用して新しいサブドメインを作成し、サブドメインがメインのpublic_htmlフォルダーを指すようにする必要がありますが、正確なヘルプを提供するには、サーバーに関する詳細情報が必要になる可能性があります。
編集:
RewriteCond %{HTTP_HOST} ^here.mypage.com [NC]
RewriteRule ^/here.html [L]
これでサブドメインができます。
here.mypage.comをmypage.com/here.htmlにリダイレクトするには、.htaccessにルールを追加するだけでは不十分です(=>サブドメインの設定を参照)。
もう1つは、次を追加できます。
RewriteRule ^now$ now/test.html
これを試してみてください:
Redirect 301 here.mypage.com mypage.com/here.html
Redirect 301 mypage.com/now mypage.com/now/test.html