5
A
回答
0
假設你使用的是Apache,下面的教程epically幫助:
第二教程有你的答案。準備深入挖掘一個名爲mod_rewrite
的地牢。
3
假設你在Apache上運行,這個代碼在.htaccess工作對我來說:
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)/$ /index.php?parameter=$1
根據您的網站結構可能需要的廣告,雖然一些規則。
0
如果您使用的是Apache,請使用mod重寫規則。這是製作虛擬目錄的更好和更安全的方式。
1
在您的Apache服務器上啓用mod_rewrite
並使用.htaccess
規則將請求重定向到控制器文件。
的.htaccess
# Enable rewrites
RewriteEngine On
# The following two lines skip over other HTML/PHP files or resources like CSS, Javascript and image files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# test.php is our controller file
RewriteRule ^.*$ test.php [L]
test.php的
$args = explode('/', $_SERVER['REDIRECT_URL']); // REDIRECT_URL is provided by Apache when a URL has been rewritten
array_shift($args);
$data = array();
for ($i = 0; $i < count($args); $i++) {
$k = $args[$i];
$v = ++$i < count($args) ? $args[$i] : null;
$data[$k]= $v;
}
print_r($data);
訪問URL http://localhost/abc/123/def/456會輸出如下:
Array
(
[abc] => 123
[def] => 456
)
相關問題
- 1. 網址:如何使GET參數看起來像目錄
- 2. 如何使哈希鏈接看起來像目錄
- 3. 使autocompletetextview看起來像edittext
- 4. 使UICollectionView看起來像UITableView
- 5. 配置NoseTests看起來的目錄
- 6. 重寫URL查詢字符串看起來像目錄
- 7. 目標文件看起來像什麼
- 8. foreach看起來不像在php
- 9. 工作目錄如何在樹形圖中看起來像?
- 10. 爲什麼bind看起來像數組一樣呈現參數?
- 11. Get-ChildItem結果看起來像Powershell中的相對路徑
- 12. Nginx重寫。 PHP GET參數在子目錄
- 13. android textpaint看起來不像textview具有相同的參數
- 14. Java Swing看起來像Windows
- 15. HttpRequestMessage如何看起來像?
- 16. wpf ListBox看起來像datagrid?
- 17. Imageview看起來像mapview
- 18. PHP - 一起剪切圖像目錄
- 19. 如何使UITextView看起來像Facebook登錄?
- 20. HTML數據,看起來像一些
- 21. WP8.1日曆看起來像
- 22. 使BorderPane看起來像一個圓圈
- 23. 使按鈕看起來像文字
- 24. 如何使leftBarButtonItem看起來像backBarButtonItem?
- 25. 使PyCharm看起來像崇高文本
- 26. Bootstrap使文本看起來像按鈕
- 27. 如何使UITableView看起來像這樣
- 28. 如何使JTextField看起來像JLabel
- 29. 如何使GtkTextView看起來像GtkEntry?
- 30. 使WPF DataGrid看起來像一個ListView
谷歌 - >的.htaccess的mod_rewrite +教程。 – sberry 2010-12-04 03:46:24