As many know, one can make a friendly URL with mod_rewrite in their .htaccess file like so:
RewriteRule ^category/(.*)$ /somescript.php?category=$1 [L]
This works as long as somescript.php is within the document root folder of the server. If someone was able to guess the actual script (example: if they typed:
http://example.com/somescript.php?category=whatever instead of
http://example.com/category/whatever), then the chances of duplicate content happening is high because at some point, someone will share the links and it may be possibly indexed in the search engines.
What I am looking for is a way to make somescript.php inaccessible to the public, yet the public should be able to access the friendly URL.
I attempted to use
ScriptAliasMatch with the same parameters as RewriteRule except I added a
/ after the
^ and I removed the
[L]. I moved the script to a folder one level up from public_html and I set the user and group name of the folder to the same as the Apache user and group and the permissions of the PHP file is 0x755.
When I attempt to access the file I receive status code 403 forbidden and in the Apache error_log, I receive
client denied by server configuration: /path/to/somescript.php
I also have set loglevel to debug.
Has anyone else been successful in launching scripts at locations inaccessible to the public when the public requests a friendly URL? If so, how did you pull it off?
And I did add the
Disallow: /*? line in my robots.txt but I think I need to do more than that as some bots don't respect robots.txt.