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
Php 无法使用htaccess重定向我的URL_Php_.htaccess - Fatal编程技术网

Php 无法使用htaccess重定向我的URL

Php 无法使用htaccess重定向我的URL,php,.htaccess,Php,.htaccess,我正在使用WAMP,我的url是localhost/hotel/hotels.php?id=21 使用如下的重写规则 Options +FollowSymLinks RewriteEngine on RewriteRule hotels/id/(.*)/ hotels.php?id=$1 RewriteRule hotels/id/(.*) hotels.php?id=$1 但是什么也没发生 我的mod_rewrite已打开,并且在httpd.conf文件中进行了更改 请给我一个处理这个问题的

我正在使用WAMP,我的url是
localhost/hotel/hotels.php?id=21
使用如下的重写规则

Options +FollowSymLinks
RewriteEngine on
RewriteRule hotels/id/(.*)/ hotels.php?id=$1
RewriteRule hotels/id/(.*) hotels.php?id=$1
但是什么也没发生

我的mod_rewrite已打开,并且在
httpd.conf
文件中进行了更改

请给我一个处理这个问题的建议

您必须为您的重写规则使用。您可以按如下方式更改它

RewriteEngine on
RewriteRule  ^hotels/id/([\d]+)/?$ hotels.php?id=$1 [NC,L]
您可以从中调用页面

localhost/hotel/hotels/id/12


如果.htaccess文件位于localhost/hotel

中,那么
hotels.php?id=21
会发生什么?我的意思是,
hotels/id/21
应该会发生一些事情,但它不会改变
hotels.php?id=21
!对我想把它改成hotels/id/21,但什么也没变。即使完成了所有操作,url仍然保持不变。您必须转到
localhost/hotel/hotels/id/21
,重写规则不是重定向!哦,谢谢。。那么如何进行重定向。在这方面你能帮我吗?你应该查看关于重定向如何将原始页面重定向到重写页面?如果有效,您可以使用。如果您的.htaccess文件位于hotel文件夹中。请检查。htaccess正在使用