Ben
Ben

Reputation: 2209

href="blaah" instead of href="blaah.php" and href=".." instead of href="index.php"

I have seen the use of href="blaah" instead of href="blaah.php" for the href attribute of the a tag. I have also seen href=".." in the stead of href="index.php".

I have tested this on an NGINX server, but, when I host, I will probably end up hosting through Apache. So, is href="blaah" supported by Apache?

Upvotes: 0

Views: 67

Answers (1)

Eragon666
Eragon666

Reputation: 28

You can use RewriteEngine for this, just add this code to your .htaccess.

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.+)$ $1.php [L]

This code adds .php to every file without a extension.

Upvotes: 1

Related Questions