views:

39

answers:

1

I am trying to hide the extensions of my scripts like .php or .html, so that the person browsing the website, will not have any idea about the language the page is developed at.

Any Idea how to do this?

A: 

i think id use the mod_rewrite like as follows:

http://gist.github.com/22877

this will allow anything with a valid page to be served but a 404 to be served if no page found

hope this helps

paul

try this

<IfModule mod_rewrite.c>
   Options +FollowSymLinks
   Options +Indexes
   RewriteEngine On
   RewriteCond %{SCRIPT_FILENAME} !-d
   RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>

put that in the .htaccess of the root and it should propagate through all sub directories as well - that will take care of .php, you will need other rules for .html/.htm etc

PaulStack
Ok, but it also should give error, if client tries to access with .php or .html extensions. You know anything related to this
Starx
you would handle that as part of your rewrite rules - infact that's very important as if you do not them potentially you have 2 different urls point to a single page and Google can penalise you for that
PaulStack
I dont have any ideas on how to be doing that? Can you guide me?
Starx
if you look at the link i sent you gives you the rewrite rules to redirect http://yoursite.com/foo to http://yoursite.com/foo.php. therefore it will pick up both the .php and non .php urls - id do something similar - all you got to do is reverse the rul - redirect anything from .php to the non .php version
PaulStack
Actually, I want to give a 404 error, if .php or .html is found
Starx
but by doing that you would then be discounting anyone who got the "actual" url of the site - IMO you would need to cater for both - but its just my thoughts for SEO purposes
PaulStack
Ok, then can you tell me the way to redirect the the links with .php with the ones without them.
Starx
i have updated my original answer
PaulStack