I write htaccess code that make my url seo friendly
RewriteEngine on
RewriteBase /
RewriteRule ^p/([^/]+)/([^/]+)$ page.php?id=$1&title=$2 [QSA]
the real page access format is page.php?id={id}&title={title}
.
And with htaccess p/{id}/{title}
So want I want to stop access page.php
with real format. is that possible ?
2
Answers
You actually cannot prevent
page.php
from accessing it in real format. The code in your.htaccess
file only rewrites the URL to be SEO friendly and it does not redirects or prevents it from accessing in real format.For example these two links will both work without any error on your server:
The only way to “prevent” accessing it from other users in real format is to change every link into SEO friendly (see
link2
) and belive in that the user does not know the original format!Try with below rule below your current rewrite rule,