我想在提交搜索表单时,网址如下:
localhost/xampp/external/proj3/search/searchquery
而不是:
localhost/xampp/external/proj3/tools/search/search.php?query=searchquery
答案 0 :(得分:3)
您可以在DOCUMENT_ROOT/.htaccess
文件中使用此代码:
RewriteEngine On
RewriteBase /xampp/external/proj3
# external redirect from action URL to pretty one
RewriteCond %{THE_REQUEST} /search(?:\.php)?\?query=([^\s&]+) [NC]
RewriteRule ^ search/%1? [R=302,L,NE]
# internal forward from pretty URL to actual URL
RewriteRule ^search/([^/.]+)/?$ search.php?query=$1 [L,QSA,NC]
答案 1 :(得分:0)
在文档根目录中创建.htaccess
文件。并把它:
RewriteEngine On
RewriteRule ^search/([a-zA-Z0-9]+)/?$ \
search.php?query=$1 \
[NC,L]
注意:注意正则表达式。小心过滤。