.htaccess config for accessing files without extentions | Sololearn: Learn to code for FREE!

+24

.htaccess config for accessing files without extentions

In apache server, I want to access the files without extention. For eg: Client Request URL is: http://myserver/filename.html Server Response would be: 404-Not Found Client Request is: http://myserver/filename Server Response would be: 200-display file I have a .htaccess config: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html But problem with this configuration is that, it doesn't return 404-error-code when, client requests file with a extention. Thanks... I hope, I'll get helped soon possible.

6/30/2019 2:26:45 PM

Space

9 Answers

New Answer

+24

David Carroll Yes

+7

🤨😥 I'm not getting my answer!!

+6

@Chris Latham I get 404 on requesting both of following URL in the browser after appending the script you gave, in the above script I have. RequestURL: http://mylocalsite/myfile Response-Code: 404 RequestURL: http://mylocalsite/myfile.html Response-Code: 404

+5

Is the same HTTP Response being served back for both Request URL variations?

+5

David Carroll is busy or if he free he will surely try to figure out Don't feel bad

+5

Chris Latham I will try that and respond you

+5

https://www.askapache.com/htaccess/using-filesmatch-and-files-in-htaccess/ I Got the Solution

+3

Space {{#always_smile_ignore_situation😃😃}} Wow... you're name is changing so much and it's so long. Anyway... sorry for not responding yet. I actually lost track and have been so busy this week. I'll try to answer today.

+1

I'm thinking that adding something along the lines of the following to your existing .htaccess might work. I don't have a server set up right now to test though. RedirectMatch 404 ^(.*).html