2017-03-16 39 views
0

你能幫我嗎我想使用htaccess清理我的網址。

http://localhost/website/index.php?page=directory&id=1 

http://localhost/website/directory/1 
+0

你可以檢查這個工具http://www.generateit.net/mod-rewrite/index.php它可以幫助你打造重寫規則 – knetsi

回答

0

使用下在自己的網站目錄的規則,

RewriteEngine On 

# neither a directory nor a file 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule ^([\w-]+)/([\w-]+)$ index.php?page=$1&id=$2 [QSA,L] 
+0

不起作用。即使在本地主機服務器上它工作嗎? – MOJOJO

+0

什麼是錯誤? –

+0

沒有結果..... – MOJOJO

0
index.php 
<a href="directory/1">click</a> 

submit.php 
<?php 
echo $_GET['id']; 
echo $_GET['page']; 
?> 

.htaccess 
RewriteEngine on 
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ submit.php?page=$1&id=$2 [NC,L] 
相關問題