top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to remove file extension from an url using php?

+2 votes
514 views
How to remove file extension from an url using php?
posted Jan 4, 2016 by Abhishek Maheshwari

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
 
Best answer

In order to remove extension from PHP files and make the URLs more user and search engine friendly. In this l I’ll show you how to do that easily, by editing the .htaccess file.

What is an .htaccess file
An .htaccess file is a simple ASCII file that you create with a text editor like Notepad or TextMate. It provides a way to make configuration changes on a per-directory basis.

Please note that .htaccess is the file’s extension. It isn’t file.htaccess, it is simply .htaccess.

Removing Extensions
To remove the .php extension from a PHP file for example yoursite.com/wallpaper.php to yoursite.com/wallpaper you have to add the following code inside the .htaccess file:

   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^([^\.]+)$ $1.php [NC,L]
answer Jan 5, 2016 by Ananya Saha
Similar Questions
+2 votes

Any pointer would be helpful?

+4 votes

Question related to a internal company knowledge transfer site. Suppose there is a tag like PHP and I want to send mail to the PHP followers when a new question is posted in PHP tag?

Can i get any logic for it ?

+2 votes

Hi,I have a url some thing like this https://google.com/.I need to replace end of slash in the url.

I need url like this https://google.com.

...