PHP

HIDE PHP EXTENSION IN THE URL WITH HTACCESS

(quick guide & examples)

# (A) RENAME PHP FILES TO PY OR ASP AddType application/x-httpd-php .py .asp

OFFICIAL SOLUTION

01

# (B) RENAME PHP FILES TO WHATEVER AddType application/x-httpd-php .foo .bar

* BAD SOLUTION - CLASHES WITH PYTHON, ASP, CONFUSING.

SIMPLE URL REWRITE

02

# (A) REWRITE ON RewriteEngine on

# (B) DO NOT OVERRIDE EXISTING FOLDERS RewriteCond %{REQUEST_FILENAME} !-d

# (C) REWRITE PHP FILES ONLY RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^([^\.]+)$ $1.php [NC,L]

* THIS WILL MAP HTTP://SITE.COM/PAGE TO PAGE.PHP

HTTPD.CONF SETTINGS

03

ENABLE MOD REWRITE LoadModule rewrite_module modules/mod_rewrite.so

* THIS WILL MAP HTTP://SITE.COM/PAGE TO PAGE.PHP

ALLOW OVERRIDE  <Directory "YOUR-HTTP-FOLDER">   AllowOverride All </Directory>