次の URL を書き換えられるようにしたい:
// examples
http://example.com/location/New York, NY -->
http://example.com/location/index.html?location=New York, NY
http://example.com/location/90210 -->
http://example.com/location/index.html?location=90210
http://example.com/location/Texas -->
http://example.com/location/index.html?location=Texas
http://example.com/location/ANYTHING.... -->
http://example.com/location/index.html?location=ANYTHING...
.htaccess
mod_rewriteを使用します。
誰でもこれを行う方法を知っていますか?
私が試してみました:
RewriteEngine on
RewriteCond %{REQUEST_URI} !location/index.html
RewriteRule ^location/(.*)$ /location/index.html?location=$1
ただし、「pretty url」 (例: http://example.com/location/90210 )を使用すると、GET ロケーション変数が /location/index.html ページに渡されません。
長いURLが使用されている場合は( javascriptを使用して)場所のGET変数を画面にエコーアウトすると、このb/cが設定されますが、きれいな(短い)URLが使用される場合、場所のGET変数は未定義です。