0

私はmobile自分のウェブサイトをcPanelで呼び出すサブドメインを作成しました。モバイルデバイスをそのサブドメインにリダイレクトしますが、実際のドメインにAJAX呼び出しを行うjavascriptがそこにあります。これらの呼び出しをに移動するように構成しましたwebsite.com/mobile/......ただし、これらは実行されておらず、それは私ので探しているためだと思いますが、リクエストは.htaccessでに/mobile書き換えられることになっています。website.com/index.php?params=mobile/...

.htaccessは次のとおりです。

# redirect phones/tablets to mobile site
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{HTTP_HOST} !mobile\.website\.com [NC]
RewriteCond %{REQUEST_URI} !^/mobile [NC]
RewriteRule ^(.*)$ http://www.mobile.website.com/$1 [L,R=302]

# not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# website.com/home => website.com/index.php?params=home
RewriteRule ^(.+)(\?.+)?$ index.php?params=$1 [L,QSA]

これは私のローカルマシンでは機能しますが、ライブサーバーでは機能しません。ローカルでsudomainを作成しました

<VirtualHost *:80>
    DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/website/mobile"
    ServerName mobile.website.local
</VirtualHost>

そしてそれは完璧に機能します:mobile.website.localまたはに行くwebsite.local/mobileとモバイルサイトを取得し、に行くとwebsite.local/mobile/users/loginAJAXリクエストの正しいJSON出力を取得します。

mobileサブドメインを存続させながら、最後の書き換えルールで転送するように/mobile/要求するにはどうすればよいですか?website.com/mobile/...

ありがとう!

4

1 に答える 1

0

/mobile に特定のリダイレクトを追加するだけで、ファイルまたはディレクトリ ステートメントを強制的に無視できます。

RewriteCond %{REQUEST_URI} ^/mobile [NC]
RewriteRule ^(.+)(\?.+)?$ index.php?params=$1 [L,QSA]

# redirect phones/tablets to mobile site
RewriteCond %{HTTP_HOST} !mobile\.website\.com [NC]
RewriteCond %{REQUEST_URI} !^/mobile [NC]
RewriteCond %{QUERY_STRING}  !^params=mobile(.*)$
RewriteRule ^(.*)$ http://www.mobile.website.com/$1 [L]

# not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# website.com/home => website.com/index.php?params=home
RewriteRule ^(.+)(\?.+)?$ index.php?params=$1 [L,QSA]

何でも教えてください、私が助けることができるかどうか見てみましょう:)

于 2012-04-17T21:31:22.660 に答える