我开发了一个不使用任何框架的项目。当点击这个时,我想将页面重定向到特定的php文件(例如:movie/imovie.php)
<a href="/movie/1/Baashha-Suresh-Krishna-1995">Click me</a>
链接。我已经创建了.htaccess文件,目前它看起来是这样的。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/movie/([0-9]+)/$ http://localhost/tthtml/movie/movie_review.php [L]
</IfModule>
我在httpd.conf文件中启用了mod_rewrite模块。我在windows机器中使用wamp服务器。
我不知道该怎么做。我引用了一些网站,并在自己的网站上创建了上述规则。请任何人帮我做这件事,如果你的回答也有脏话,我会感觉更好。提前谢谢。
修改规则如下:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^movie/([0-9]+)/(.*)$ http://localhost/tthtml/movie/movie_review.php [L]
</IfModule>
您设置的规则不起作用,因为它只比较字符串"/moime/1/",而您实际上想要匹配"/moine/1/Bashha-Suresh-Krishn-1995"。
为了实现这一点,我将RewriteRule指令修改为^/movie/([0-9]+)/(.*)$
,以容纳剩余的字符串"Baashha-Suresh-Krishn-1995"或应用程序可能具有的任何其他值。