Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 htaccess 创建对 SEO 友好的 URL,如下所示:
RewriteRule ^search/page/(.*)$ /search.php?page=$1
所以效果很好。当我输入 /search/page/2/ 时,它会正确重定向。但是人们仍然可以通过输入 /search.php?page=2 来访问它。我怎么能不允许呢?它应该被发送到 404 页面还是返回到 /search/page/2/?
我希望这个能帮上忙
RewriteCond %{QUERY_STRING} ^page=(.*) RewriteRule ^search.php /search/page/%1/? [R,L]
试试这个重定向到新的 URL:
RewriteCond %{QUERY_STRING} page=(.*) RewriteRule ^search.php /search/page/%1 [R=301,L]