Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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重写规则和get参数_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

.htaccess重写规则和get参数

.htaccess重写规则和get参数,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,我需要能够重写http://example.com/staging/details/?postid=23使其成为http://example.com/staging/grandhotelterduin 我不确定.htaccess规则应该是什么 我想出了这样的办法 Options +FollowSymLinks RewriteEngine On RewriteRule ^grandhotelterduin/(.*)$ ./details/?postid=23 [L,NC] 我不确定我做的

我需要能够重写
http://example.com/staging/details/?postid=23
使其成为
http://example.com/staging/grandhotelterduin

我不确定.htaccess规则应该是什么

我想出了这样的办法

Options +FollowSymLinks  
RewriteEngine On 

RewriteRule ^grandhotelterduin/(.*)$ ./details/?postid=23 [L,NC]
我不确定我做的是否正确,你能帮忙吗

我希望它的
http://example.com/staging/grandhotelterduin/
重定向到
http://example.com/staging/details/?postid=23
但浏览器中显示的url是`

请使用以下内容:

RewriteEngine On
RewriteRule ^grandhotelterduin$ /staging/details/?postid=23 [L]
它将为您提供以下URL:

http://sheetz.nl/grandhotelterduin

编辑:


你可以再次检查规则吗?你可以尝试我的编辑,但是当我测试我以前的规则时,它起了作用。确保规则位于
.htaccess
的顶部,并且缓存已清除。
RewriteCond %{THE_REQUEST} /staging/details/?postid=([0-9]+)  [NC]
RewriteRule ^ /staging/grandhotelterduin [L,R]