2017-03-16 37 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] 
相关问题