Jump to content

How to drop the .txt extension from all requests in a certain directory???


pparker

Recommended Posts

Greetings,

I would like to drop the .txt extension from all requests to text files in a certain directory. For your information, I am running Red Hat Enterprise Linux 4.0 with Apache 2.0.52.

 

So this request: http://localhost/data/example.txt

 

would be changed to: http://localhost/data/example

 

The reason I am requesting your help is because this is basically the opposite of what most people try to do with mod rewrite. I have the code below that adds a file extension of .txt.  I imagine that the code to remove an extension would be similar.

 

  RewriteEngine On

  RewriteCond %{REQUEST_fileNAME} !-d

  RewriteCond %{request_URI} !(\.[^./]+)$

  RewriteRule (.*) /$1.txt [L]

 

Does anyone know what the code would look like to remove a .txt extension? Any help is greatly appreciated.

 

Thanks,

Peter

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.