我有如下网站链接。
justrite.pl/exam.php?code=/product1.htm
justrite.pl/exam.php?code=/product2.htm
justrite.pl/exam.php?code=/product3.htm
以及许多产品,如产品4,产品5......产品100
如果有人访问该网站,应该看到下面给出的这些链接
justrite.pl/product1.htm
justrite.pl/product2.htm
justrite.pl/product3.htm
请帮助使用 HTaccess实现它。
您可以像这样使用.htaccess
规则:
RewriteRule ^product1.htm$ exam.php?code=product1.htm [L]
RewriteRule ^product2.htm$ exam.php?code=product1.htm [L]
RewriteRule ^product3.htm$ exam.php?code=product1.htm [L]
尽可能添加更多。
这应该可以做到:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /exam.php?code=$1 [L]
它还检查是否有具有最初请求名称的目录或文件,以便它不会重定向它们。