Artificial Intelligence Programming Lab(AIPLab) 討論區

Please login or register.

請輸入帳號, 密碼以及預計登入時間



作者 主題: Apache mod_rewrite Introduction  (閱讀 1260 次)


  • 管理員
  • Hero Member
  • *****
  • 文章: 1897
    • 檢視個人資料
Apache mod_rewrite Introduction
« 於: 三月 19, 2016, 03:10:02 am »

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?lang=$1 [L,QSA]

%{REQUEST_FILENAME} The full local filesystem path to the file or script matching the request,

a '!' character (exclamation mark) to negate the result of the condition
-f Is regular file.
-d Is directory.
[PT] The target (or substitution string) in a RewriteRule is assumed to be a file path, by default. The use of the [PT] flag causes it to be treated as a URI instead.
[L] flag causes mod_rewrite to stop processing the rule set.
[QSA] When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.

SimplePortal Classic 2.0.5