私は次のセットアップを持っています
go.me.com/123
go.me.com/anything
リダイレクトしたいのですme.com
が、特定の番号を特定のページにリダイレクトさせます。
それは可能ですか?
サンプル溶液
mod_rewrite と .htaccess を有効にしてからhttpd.conf
、このコードをディレクトリの.htaccess
下に配置します。DOCUMENT_ROOT
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# first specific rules for specific URIs
RewriteCond %{HTTP_HOST} ^go\.me\.com$ [NC]
RewriteRule ^10$ /sample1 [L,R=302]
RewriteCond %{HTTP_HOST} ^go\.me\.com$ [NC]
RewriteRule ^20$ /sample2 [L,R=302]
# now anything rule
RewriteCond %{HTTP_HOST} ^go\.me\.com$ [NC]
RewriteRule . / [L,R=302]
正常に動作していることを確認したら、 に置き換えR=302
ますR=301
。R=301
mod_rewrite ルールをテストしている間は (Permanent Redirect) を使用しないでください。