Setting up Apache to allow URLs without specifying file extensions
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.
Thanks in advance!
Busy posted this at 11:36 — 1st October 2005.
He has: 6,151 posts
Joined: May 2001
mod_rewrite in .htaccess
RewriteRule ^filename*$ filename.php (or whatever extension)
search.php becomes search
triapply posted this at 01:01 — 2nd October 2005.
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 posted this at 09:50 — 2nd October 2005.
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.
triapply posted this at 15:17 — 2nd October 2005.
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.