好的,我是非常新的,我真的很感激一些帮助,谢谢!
我怎样才能正确地重写.htaccess?
所以我在我的网址中有一个查询字符串:
/?url=contact
Run Code Online (Sandbox Code Playgroud)
我想要做的就是删除查询字符串
/contact
Run Code Online (Sandbox Code Playgroud)
救命?我搜索谷歌,我现在正在学习语法,但事实仍然是......我不知道该怎么做.谢谢大家
ran*_*dom 27
试试这个:
RewriteEngine On
RewriteRule ^(.*)$ /index.php?url=$1 [L]
Run Code Online (Sandbox Code Playgroud)
对于您网站上的用户,他们会看到并导航到此:
http://example.com/contact
Run Code Online (Sandbox Code Playgroud)
但真正的页面将是这样的:
http://example.com/index.php?url=contact
Run Code Online (Sandbox Code Playgroud)
这一位[L]告诉服务器这是重写规则的最后一行并停止.
Dev*_*tas 18
RewriteCond %{QUERY_STRING} url=(.*)
RewriteRule index.html %1
Run Code Online (Sandbox Code Playgroud)
(或者如果它不是index.html,index.php,等等)
您需要捕获查询字符串,而RetrriteRule通常不会查看该字符串,并使用%1返回引用,而不是像RewriteRule中的捕获那样使用$ 1