http://example.com/links/AAA
からhttp://links.example.net/l/AAA
(AAA
は変数)へのリダイレクトを作成しようとしています。私はそれが働いている。問題は、http://example.com/links/
とhttp://example.com/links
の両方がhttp://links.example.net
(/l/
なし)にリダイレクトされることです。.htaccessクロスドメインリダイレクト
http://example.com/links/
はhttp://links.example.net/l/
にリダイレクトされ、example.com/links
はhttp://links.example.net/l//hsphere/local/home/username/example.com/links
にリダイレクトされます。
現在.htaccess
:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} (.+)$ [NC]
RewriteRule ^(.*)$ http://links.example.net/l/$1 [R=301,L]
</IfModule>
擬似コード:私はここに他の.htaccess
質問の束に目を通してきた
if ($path) {
goto(http://links.example.net/l/${path}/); // Adding the trailing slash is not necessary, but would be handy. Obviously, don't add if it already exists.
} else {
goto(http://links.example.net/);
}
(良い悲しみが非常に多くある)が、同等の何かを見つけるためには至っていません。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php/$1
</IfModule>
をそして、私は自宅でもう少しだPHPでリダイレクトを実行します。
必要であれば、私はこの別の方法を行うことができます。しかし、それは(a)効率が悪く、(b)楽しくなく、(c)教育が難しいということです。だから私はこれを正しい方法でやろうとしています。
ありがとうございます。私は明日の朝にその最初のことを試し、あなたに報告します。 – TRiG