2014-02-20 26 views
1

什麼我已經是這樣的網址:的.htaccess重寫與位置哈希網址

domain.com/index.php?chapter=chapter-name 

和URL鏈接此:

domain.com/index.php?marker=marker-name 

我要的是:

domain.com/#chapter-name 

和這個:

domain.com/#chapter-name/marker-name 

我該如何使用.htaccess來做到這一點?

我現在有以下幾點:

RewriteEngine On 
RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 
RewriteRule ^([a-zA-Z0-9_-]+)?$ index.php?chapter=$1 
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?chapter=$1 

謝謝!

+3

'#'是一個網址片段,以這種方式使用它可能不會產生你所追求的效果:http://blog.httpwatch.com/2011/03/01/6-things-you-should- know-about-fragment-urls/ – CD001

+0

你不能通過htaccess來完成,而是使用Javascript。 – anubhava

+0

第二個請求實際上是:domain.com/index.php?chapter=chapter-name&marker=marker-name? –

回答

0

爲了讓章工作,試試這個規則:

RewriteRule ^index.php\?chapter=([a-zA-Z0-9_-]+)$ http://www.%{HTTP_HOST}/#$1 

你的第二個需求是任意的...如何標記「知道」,這章......也許你的意思是這對你的第二個要求:

domain.com/index.php?chapter=chapter-name&marker=marker-name 
0

你不能。基本上#是一個客戶端的東西,從來沒有發送到服務器。因此.htaccess將無法​​工作。