mod rewrite - Prevent users from accessing files using non apache-rewritten urls -
may noob question i'm starting playing around apache , have not found precise answer yet.
i setting web app using url-rewriting massively, show nice urls [mywebsite.com/product/x] instead of [mywebsite.com/app/controllers/product.php?id=x].
however, can still access required page typing url [mywebsite.com/app/controllers/product.php?id=x]. i'd make not possible, ie. redirect people error page if so, , allow them access page "rewritten" syntax only.
what easiest way that? , think necessary measure secure app?
rewritecond %{redirect_url} ! ^/app/controllers/product.php$ rewriterule ^app/controllers/product.php$ /product/x [r,l] rewriterule ^product/(.*)$ /app/controllers/product.php?id=$1 [l]
the first rule redirect request /app/controllers/product.php
no redirect_url
variable set clean url. rewrite (last rule) set variable when calling real page , won't redirected.
Comments
Post a Comment