我對mod_rewrite有點困惑。
如何編寫一個規則,決定如下:PHP/Apache:用.htaccess重寫規則
如果我瀏覽/EN /頁/頁我想改寫這個來?
的index.php語言= EN &頁= /頁
,但如果我只是瀏覽/頁我想改寫這個來?
index.php頁面= /頁
這可能嗎?
編輯:
/頁僅僅是一個隨機動態頁面名稱,它可能是藏漢任何。
我需要一個規則來檢查/ se ==一個字符串,並且不超過2個字符>/page - > index.php?lang = se & page =/page如果瀏覽頁面/頁面?注意到/頁==超過2個字符,並改寫爲index.php頁面= /頁
EDIT2: 發現的大雁我的問題:
RewriteEngine On RewriteBase/ ## Check if its not a filename or dirname RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ## Rewrite rules RewriteRule ^(.{2})/(.*)$ index.php?lang=$1&page=$2 [L] RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
嗨,看看我上面的編輯:-) – Fredrik