File Extensions

Is it possible to hide the file extension from a link without using folders, index.html files or Cloudflare?

Yes, follow this topic:

2 Likes

So I just need to add that code to the top of the .htaccess file and it’ll work?

Yes, it should. However, the file will be available with the file extension too (at least I think).

1 Like

That’s good. That’s what I want.

1 Like

Yes, add that code and it will remove the .php and .html extensions. Make sure the .htacess file is inside the /htdocs folder. Clear your cache or hard refresh to view changes.

It won’t work.

With extension: http://files.rydercragie.com/Website_Sitemap.txt

Without extension: http://files.rydercragie.com/Website_Sitemap

This is what the file looks like:

Also, I haven’t got a clue what this is:

php_value display_errors On
php_value mbstring.http_input auto

But let’s not worry about that as long as it’s not the cause of this not working.

What is the location of this file? Also, it only works for HTML and PHP files.

That is because you only added it for .php and .html extensions.
Copy this and add it below the one for HTML:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.txt [NC]
RewriteRule ^ %1 [R,L,NC]
2 Likes

It’s in hotdocs. And it was a txt file. That’ll be why.

Where do I put that in the file? I’m dumb when it comes to this stuff.

Below the last rewrite rule line but before the php_value line. I really dosent matter were as long as it is after the “RewriteEngine on” line.

Done, but it won’t work.

It is working just fine for me. Try clearing you cache.

Still won’t work. Let me reset a VM and try it. I sometimes wish browser cache didn’t exist. I’d rather my browser be slower than not work.

Your ISP could be caching. Try a cellular network

1 Like

Still won’t work. I’ll ask my friend who’s in another country.

Might be waiting a while. It’s 3am where he is. Won’t work in a new VM either.

Great.

I just tried typing it into RedirectDetective.com and it says there’s no redirects, so I’ll take your word for it.

Now it isn’t working WITH the file extension!!! What the hell?

Edit: I removed everything I added to the htaccess file. That fixed it. :joy: