www.xxx.xxx.jp/pc/index.phpと表示されてしまいます。pc/index.phpを表示させない方法を教えて下さい。
サーバでSSIが使えるなら、
<!--#if expr="$HTTP_USER_AGENT = /DoCoMo/" --> <!--#include file="mobile/index.php" --> <!--#elif expr="$HTTP_USER_AGENT = /J-PHONE/" --> <!--#include file="mobile/index.php" --> <!--#elif expr="$HTTP_USER_AGENT = /Vodafone/" --> <!--#include file="mobile/index.php" --> <!--#elif expr="$HTTP_USER_AGENT = /MOT-V980/" --> <!--#include file="mobile/index.php" --> <!--#elif expr="$HTTP_USER_AGENT = /MOT-C980/" --> <!--#include file="mobile/index.php" --> <!--#elif expr="$HTTP_USER_AGENT = /SoftBank/" --> <!--#include file="mobile/index.php" --> <!--#elif expr="$HTTP_USER_AGENT = /UP.Browser/" --> <!--#include file="mobile/index.php" --> <!--#elif expr="$HTTP_USER_AGENT = /PDXGW/" --> <!--#include file="mobile/index.php" --> <!--#elif expr="$HTTP_USER_AGENT = /ASTEL/" --> <!--#include file="mobile/index.php" --> <!--#elif expr="$HTTP_USER_AGENT = /Google Wireless Transcoder/" --> <!--#include file="mobile/index.php" --> <!--#else --> <!--#include file="pc/index.php" --> <!--#endif -->
などと記述したindex.shtmlファイルをwww.xxx.xxx.jp/index.shtmlに配置し、
振り分けと同時にインクルードするのが簡単かと思います。
ただしwww.xxx.xxx.jp/pc/index.phpをwww.xxx.xxx.jp/として表示した場合、
他のファイルへのパスが相対である場合はエラーとなるため、
www.xxx.xxx.jp/に配置するような記述にする必要があります。
http://www.tohoho-web.com/wwwssi.htm#Include
他にもhtaccess、PHP、CGIなどで行う方法があります。
これはSEO対策でよく使う方法のようですが、
www.xxx.xxx.jp/pc/index.php
を
www.xxx.xxx.jp/pc/index/
のようにディレクトリーとして見せかけて表示するという手があります。
これを応用してみてはいかがでしょうか?
なぜ表示したくないのかわかりませんが、例えば
www.xxx.xxx.jp/pc/index/
の/pc/index/を別の文字で置き換えれば
www.xxx.xxx.jp/(別の文字)/
とすることもできます。
詳しくは下記サイトを参考にしてください。
コメント(0件)