+ 25

.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.

30th Jun 2019, 2:26 PM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
9 Respostas
1st Jul 2019, 10:14 AM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
+ 7
🤨😥 I'm not getting my answer!!
2nd Jul 2019, 2:19 PM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
+ 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
4th Jul 2019, 4:29 PM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
+ 5
Is the same HTTP Response being served back for both Request URL variations?
30th Jun 2019, 3:35 PM
David Carroll
David Carroll - avatar
+ 5
David Carroll is busy or if he free he will surely try to figure out Don't feel bad
2nd Jul 2019, 2:25 PM
Charan Leo25
Charan Leo25 - avatar
+ 5
Chris Latham I will try that and respond you
3rd Jul 2019, 3:37 AM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
4th Jul 2019, 4:46 PM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
+ 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.
2nd Jul 2019, 2:29 PM
David Carroll
David Carroll - avatar
+ 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
3rd Jul 2019, 3:15 AM
Chris Latham
Chris Latham - avatar