Setting up Apache to allow URLs without specifying file extensions

He has: 14 posts

Joined: Sep 2005

Hi,

I'm having trouble with setting up configurations on Apache for allowing URLs to display without file extensions specified.

For instance,
The URL can be "http://www.site.com/sampledir/search"

.. but can be implemented using search.php, search.jsp or search.aspx...

---
I know this is possible and I have tried searching online as well as on other forums, but ended up reading and trying without results for over 3 hrs.

I've tried:

1. MultiViews - I added this in the httpd.conf file, on the Options

Options ... MultiViews

2. ForceType directive - in .htaccess file
---
What I need is a "noobified" version of how to do this - step by step would be ideal.
Sticking out tongue

Thanks in advance!

Busy's picture

He has: 6,151 posts

Joined: May 2001

mod_rewrite in .htaccess

RewriteRule ^filename*$ filename.php (or whatever extension)

search.php becomes search

He has: 14 posts

Joined: Sep 2005

Sorry, I'm still not getting this.

I placed my .htaccess file in htdocs/mydir and I have the content below:
[
RewriteRule ^search*$ search.php
]
but I keep getting server error 500. Can you please walk me through how to set up mod_rewrite? Or maybe help me troubleshoot this?

Anyone else know why?

Busy's picture

He has: 6,151 posts

Joined: May 2001

Sorry, you said you did forcetype so figured you'd know Rewrite

RewriteEngine On
RewriteRule ^search*$ search.php

depending on your server set up may need to add Options +FollowSymlinks above that.

He has: 14 posts

Joined: Sep 2005

Thanks

I have another question - do I have to write "RewriteRule ^filename*$ filename.php" EVERY SINGLE TIME I add a file? It just seems to me that there should be a way to just have a generic definition of some sort like a variable in regular expression. I'm actually new to regex as well. So any tips on that would definitely help.

Thanks, btw.. you've been a great help so far.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.