0

How to make my websits login form page to be "/login" instead of "/login.php" or "/login.html" Id like my website to only display the directory " /login" . Any replies and tips are well recieved. thanks.

  • Possible duplicate of [Remove .php extension with .htaccess](http://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess) – CalvT May 18 '17 at 23:52

4 Answers4

2

A simple solution would be to rename your "login.php" to "index.php" and place it in it's own folder called "login"

1

URL rewriting with PHP

There is existed answer that can solve you problem.

Use URL rewrite login into login.php

Community
  • 1
  • 1
Tomi
  • 151
  • 4
0

I accomplish this with .htaccess -- This allows http://exmaple.com/whatever.php to be seen as simply http://example.com/whatever:

Options -MultiViews
RewriteEngine on

# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# add php if possible
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

# rewrite other to index.php file
RewriteRule ^ /index.php [L]
Zak
  • 6,976
  • 2
  • 26
  • 48
0

To remove the .php and .html extension in the url and make website.com/login.php or website.com/login.html display as website.com/login add the following code inside your .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php


RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html

</IfModule>

(Not tested).