我做了mod_rewrite真正的基本規則,並不能使其工作。 我想要的網址: 「https://www.example.com/index.php?req=login」 是 「https://www.example.com/login」mod_rewrite規則不起作用沒有文件擴展名
的htaccess文件是這樣的:
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?req=$1 [L]
我重定向到的index.php,但如果我打印$ _GET的結果是這樣的:
Array ([req] => index.php)
當它應該是「登錄」,而不是「的index.php」
如果我把一個擴展通緝規則爲.html和使得R因爲這個:
RewriteRule ^([^/]*)\.html$ /index.php?req=$1 [L]
它工作得很好,我得到了「請求」鍵與「登錄」值想要的。
不能弄清楚如何使它無延長地工作。
更新: 添加在模式的開頭部分串也能正常工作:
RewriteRule ^request/([^/]*)$ index.php?req=$1 [L]
這也將mach'/page/subpage'並將其重寫爲'index.php?req = page'我不確定這是否是有意的,但是/ page1'將不起作用 – Webdesigner