here is my rules for htaccess file.
RewriteRule ^admin/?$ admin/index.php
RewriteRule ^cart/([0-9]+)/?$ cart.php?t=$1
RewriteRule ^register$ register.php
RewriteRule ^login$ login.php
RewriteRule ^forgot-password$ forgot_password.php
RewriteRule ^terms-and-conditions$ terms_and_conditions.php
RewriteRule ^request-consideration$ request_consideration.php
RewriteRule ^([a-z0-9\-]+)/?$ products.php?cid=$1
RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)/?$ products.php?cid=$1&scid=$2
RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)/([a-z0-9\-]+)/?$ product_details.php?cid=$1&scid=$2&id=$3
ErrorDocument 404 /error_404.php
Now the problem is when i try to redirect it say www.example.com/cart/123 it goes products.php page. I want to restrict the url www.example.com/cart/123 only. so www.example.com/cart or www.example.com/cart/abc will redirect to error_404 page. same for other also like register, login etc.
Any help would be appreciated. Thanks in advance.
答案 0 :(得分:0)
根据您的评论,如果要求 / cart 或 / cart / abc ,您希望将uri重定向到404页面,则可以使用以下规则。在其他RewriteRules之前将它放在htaccess的顶部
RewriteEngine on
RewriteRule ^cart/?$ - [R=404,L]
RewriteRule ^cart/[A-Za-z]+/?$ - [R=404,L]