我要讓類似:變量作爲www.example.com/var1/var2/
www.example.com/var1/var2/
在那裏我可以把變量的值,但它也需要與GET
喜歡兼容:
www.example.com/var1/var2/?feat=1234
我該怎麼做?
感謝
我要讓類似:變量作爲www.example.com/var1/var2/
www.example.com/var1/var2/
在那裏我可以把變量的值,但它也需要與GET
喜歡兼容:
www.example.com/var1/var2/?feat=1234
我該怎麼做?
感謝
<?php
$url = $_SERVER['REQUEST_URI'];
$url_splitter = explode('/', $url);
echo '<pre>';
print_r($url_splitter);
?>
現在,你可以通過$url_splitter[0]
,$url_splitter[1]
訪問的變量,....
但這需要我有名爲var1和var2的文件夾... – Xriuk
的文件將解釋如何做一個國防部重寫,以獲得您想要的網址。
的部分重新寫入可以這樣做(沒有測試)
http://forums.devshed.com/apache-development-15/partial-mod-rewrite-454669.html
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?var1=$1&var2=$2 [QSA,L]
那應該把像/foo/bar/?var3=baz
一個網址爲/index.php?var1=foo&var2=bar&var3=baz
我不知道它會工作,但因爲我不知道mod重寫中的正則表達式是如何工作的。
http://stackoverflow.com/questions/ 16388959/URL重寫與 - PHP。此鏈接將有所幫助 –
上述鏈接中的'.htaccess'路徑將需要標記'[QSA]'作爲示例鏈接工作 – SmokeyPHP
@Bora看起來OP只想部分重寫'?this = 1&andthis = 2&butnotthis = 3'到'/ 1/2?butnotthis = 3' – HMR