2011-04-30 3 views
1

せずに自分のサイトのURLがwww.site.comhtaccessの書き換えのindex.phpとユーザーの訪問は= site.com私は</p> <p>場合をwww.site.comにするために301でリダイレクトする必要がある場合は、WWW

ある場合にリダイレクトユーザーの訪問= www.site.com/index.php/asd 301でwww.site.com/asdにリダイレクトする必要があります

ユーザーが訪問した場合= site.com/asd 301をwwwにリダイレクトする必要があります。 site/asd

これらの条件はすべて.htaccessファイルから取得できますか?誰も私を助けることができますか? :)

感謝;)

+0

関連します:http://serverfault.com/questions/145109/howto-redirect-http-to- https-on-the-same-httpd – cregox

答えて

0

は、あなたの.htaccessファイルにこれらのルールを試してみてください。

Options +FollowSymlinks -MultiViews 
RewriteEngine on 

RewriteCond %{THE_REQUEST} ^GET\s/index.php [NC] 
RewriteRule ^index.php/(.*)$ /$1 [R=301,L,NC] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L] 

RewriteCond %{HTTP_HOST} ^site\.com$ [NC] 
RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,NC] 
+0

uhm ... tryedは動作するが、決まっていない:P – moment

+0

私はcodeがsite.comからwww.site.comにリダイレクトされているが、site.com/asdに行くと私はwww.site.com/index.php/asdにリダイレクトされますが、私はwww.site.com/asdにリダイレクトしたいと思っています。 – moment

+0

これは非常に奇妙です。 .htaccessファイル内の唯一のコードは上記ですか?上のどこに 'index.php/asd'にそれを送りますか。実際、上記の2番目のRewriteRuleは '/ ads'に 'index.php/asd'を作成しています。もしあなたがaccess.logのいくつかの関連部分のスニペットを貼り付けることができれば、それをデバッグする助けにもなります。 – anubhava