Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
.htaccess htaccess重写查询字符串无效_.htaccess_Rewrite - Fatal编程技术网

.htaccess htaccess重写查询字符串无效

.htaccess htaccess重写查询字符串无效,.htaccess,rewrite,.htaccess,Rewrite,问题 在查看了50多篇StackOverflow文章并尝试了我的htaccess文件的许多排列之后,它仍然没有做任何事情 我尝试过的 使用此网站生成我的htaccess文件: 在httpd.conf文件中设置AllowOverride All并重新启动Apache 我当前的HTACCESS文件 位于根目录中 RewriteEngine On RewriteBase / RewriteRule ^find-a-local-doctor/([^/]*)/([^/]*)$ /find-a-local-

问题

在查看了50多篇StackOverflow文章并尝试了我的htaccess文件的许多排列之后,它仍然没有做任何事情

我尝试过的

使用此网站生成我的htaccess文件:

在httpd.conf文件中设置AllowOverride All并重新启动Apache

我当前的HTACCESS文件

位于根目录中

RewriteEngine On
RewriteBase /
RewriteRule ^find-a-local-doctor/([^/]*)/([^/]*)$ /find-a-local-doctor/?state=$1&city=$2 [L]
我想要实现的目标

更改此URL:

为此:

另外

由于实际执行工作的文件是:,因此我需要能够使用PHP解析查询字符串。希望,我仍然能够做到这一点,以获得国家和城市

请帮忙。
谢谢。

您现有的规则看起来不错,但是您需要一个额外的外部重定向规则来进行反向。将此规则置于现有规则之前(就在
RewriteBase/
的下方)


看起来不错,你现在面临的问题到底是什么。请说明清楚。当我转到url时,它不会按照我想要的方式被重写。它没有任何作用。尝试将此添加到我的原始规则中,但它仍然没有任何作用。哦,我在上面的规则中找到了
/
之后,我的
丢失了
查找本地医生。代码已编辑,请立即尝试。好的,可以了,但现在我的页面抛出了404错误,而不是将查询字符串参数传递到index.php页面。此外,我希望它可以用于进行另一次编辑,该编辑将负责重写http://www.md1network.com/find-a-local-doctor/index.php?state=FL&city=Tampa
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(find-a-local-doctor)/(?:index\.php)?\?state=([^&]+)&city=([^&\s]+) [NC]
RewriteRule ^ /%1/%2/%3? [R=301,L]