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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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