Php 无法使用htaccess重定向我的URL
我正在使用WAMP,我的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文件中进行了更改 请给我一个处理这个问题的
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正在使用