我想重寫htaccess的接受搜索引擎友好的查詢字符串,友好的URL重寫規則的查詢字符串
,我曾經通過URL參數傳遞的老方法是:
http://sitename.com/foldername/edit-agent.php?name=John-Smith
我想改變上述網址:
http://sitename.com/foldername/edit-agent/John-Smith
我htaccess文件規則如下:
<files page>
ForceType application/x-httpd-php
</files>
<IfModule mod_rewrite.c>
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule ^edit-agent/([^/\.]+)/?$ edit-agent.php?name=$1 [L]
#resolve .php file for extensionless php urls
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
</IfModule>
得到傳遞參數,在edit-agent.php
文件,我用:
$agent_name = preg_replace('/[^a-zA-Z]/', '', $mysqli->real_escape_string($_GET['name']));
當我到URL http://sitename.com/foldername/edit-agent/John-Smith
,頁面顯示內部服務器錯誤
對此事的任何線索?
難道你錯過了你的規則中的「文件夾名稱」嗎? – Coder 2014-09-19 07:42:15