The title says it all.
This is what it looks like now: I'd like to make it look like "psychops.tk/index (I may rename it to "home" to make it better). And same goes for every other page on the website
Asked
Active
Viewed 55 times
-2

Hilex23
- 337
- 2
- 11
-
3There are literally thousands of duplicates, going back more than a decade. Googling your *exact title* (["How do I hide the file extension in the URL?"](https://www.google.com/search?q="How+do+I+hide+the+file+extension+in+the+URL%3F")) finds https://stackoverflow.com/questions/6534904/how-can-i-remove-file-extension-from-a-website-address as the first result. Eleven years ago, somebody chided the author of *that* question due to the number of duplicates that already existed. Learning to do some research via Google before asking for help is a critical skill to acquire. – user229044 Dec 04 '21 at 00:29
1 Answers
0
Create a .htaccess and copy the code below into it. The file should be saved in the root directory of your project.
RewriteEngine On
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
Now the .php extension will no longer appear on all your PHP files.

tyazeez
- 335
- 1
- 6
-
-
There are two things you must do for it to work, first make sure it is a .htaccess file and not just a text file, second thing is you have to place it in the root directory of your project – tyazeez Dec 04 '21 at 17:11
-
Yes, it is a .htaccess file. What do you mean by "in the root directory"? I saved it in the same place where's there's index.php (so basically no folder, just the file main folder), is that the right place? – Hilex23 Dec 05 '21 at 15:06
-
Yes your root directory is where your index.php file is saved. So I guess it was saved in the correct location. – tyazeez Dec 05 '21 at 15:18
-
-
-
-
No I mean are developing in your local machine or it's hosted on a paid server – tyazeez Dec 05 '21 at 19:57
-
-
Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/239861/discussion-between-tyazeez-and-hilex23). – tyazeez Dec 05 '21 at 21:01