Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 通过mod rewrite从url中删除查询字符串_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache 通过mod rewrite从url中删除查询字符串

Apache 通过mod rewrite从url中删除查询字符串,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我是一个非常新的修改重写,所以任何帮助将被感谢 假设我有一个名为“www.sitename.com/index.php?p=contact”的网站 我需要删除“index.php?p=” 所以它看起来像“www.sitename/contact” 每次出现时,这意味着要么我可以截断“index.php?p=”,要么我可以用一些单词替换它。@zerkms RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.*) index.php?p=$1 你的答

我是一个非常新的修改重写,所以任何帮助将被感谢

假设我有一个名为“www.sitename.com/index.php?p=contact”的网站 我需要删除“index.php?p=” 所以它看起来像“www.sitename/contact” 每次出现时,这意味着要么我可以截断“index.php?p=”,要么我可以用一些单词替换它。

@zerkms
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?p=$1
你的答案无效,它不完整

应该有

RewriteCond %{REQUEST_URI} ^/[^.]+$
RewriteRule (.*) index.php?p=$1
这些行匹配URI,不带扩展名,所以.php和.html文件
将仍然可用

smarty
标记以及
php
,与此问题无关。您还可以添加
mod rewrite
标记