簡體   English   中英

mod_rewrite /$variable/file.php

[英]mod_rewrite /$variable/file.php

我一直在嘗試嘗試此操作,但無法產生任何結果。 我試圖將變量重寫為多個文件的url中的“目錄”。.我更好地解釋了這是我的意思。

無需重寫:

/index.php?var=test

/admin/panel.php?var=test

/faq.php?var=test

/directory/test.php?var=test

用重寫:

/test/index.php

/test/admin/panel.php

/test/faq.php

/test/directory/test.php

我也希望能夠將其他變量傳遞到文件中。

/test/index.php?user=1&session=1233445

我意識到我可以為每個物理文件和目錄執行重寫規則。但是我希望它是動態的,因此,如果我將文件添加到站點,則不必繼續編輯.htaccess文件。 任何幫助,將不勝感激。 謝謝!

嘗試:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(.*?/?)(index|panel|faq|test)\.php$ /$2$3.php?var=$1 [L,QSA]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM