1

For example I have url like http://localhost/Experiments/login/login.php

I have hide the extention of file putting below code in .htaccess file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME}\.png -f
RewriteRule ^(.*)$ $1.png
RewriteCond %{REQUEST_FILENAME}\.css -f
RewriteRule ^(.*)$ $1.css
RewriteCond %{REQUEST_FILENAME}\.js -f
RewriteRule ^(.*)$ $1.js
RewriteCond %{REQUEST_FILENAME}\.jpg -f
RewriteRule ^(.*)$ $1.jpg
RewriteCond %{REQUEST_FILENAME}\.ico -f
RewriteRule ^(.*)$ $1.ico

how can I make the above url to http://localhost/login Even I tried for the solutions related to the same issue in stackoverflow but could not make it

3
  • yes, I don't want to show the folder names and file extension in the url @anubhava Commented Aug 28, 2018 at 11:51
  • Is it needed only for /Experiments/login/login.php file or for all the php files in /Experiments/login/ directory? Commented Aug 28, 2018 at 11:53
  • all the php files in the Experiments/login/ directory @anubhava Commented Aug 28, 2018 at 11:56

1 Answer 1

1

Insert this rule just below RewriteEngine On line:

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}/Experiments/login/$1.php -f
RewriteRule ^([\w-]+)/?$ Experiments/login/$1.php [L]

# remaining rules go below this
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.