I've always added the file extension to a link "contact.php" is there anything wrong with excluding it and simply having <a href="contact">
? seems to work fine, as Im having a lot of trouble with .htaccess removing the file extensions.
thx
Asked
Active
Viewed 58 times
0

Pekka
- 442,112
- 142
- 972
- 1,088

Dirty Bird Design
- 5,333
- 13
- 64
- 121
1 Answers
1
If this works, then probably thanks to Apache's content negotiation / MultiViews. A proper set of mod_rewrite rules would be more reliable because it doesn't rely on Options +MultiViews
being activated on the server, but if it works on the server it will be running on in the long term, it should be fine.
Here is an answer that should point you in the right direction if you still want to use mod_rewrite.
-
@Pekka I saw that link earlier, unfortunately, it doesn't remove extensions in the url for me. I also have some different requirements see: http://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess – Dirty Bird Design Oct 26 '10 at 18:44
-
@Dirty Gumbo's example in the linked question should work fine. I'll post an answer – Pekka Oct 26 '10 at 18:48
-
@Dirty ah, no, there are some pitfalls that I would have to research myself, can't do that right now, sorry. I'll post what I can come up with off the top of my head. – Pekka Oct 26 '10 at 18:51
-
actually when I put it on a server where the files were in the root, it works fine. when I put it in a test directory on a server it was going to the root directory and of course coming up with a 404. 2 questions if you have time 1. I'm doing some PHP link checking to add a class "current" in the nav include file, can i strip .php off the extension here
- >home
and it will be ok? also how do I exclude one page, I have a session appended url to make sure they – Dirty Bird Design Oct 26 '10 at 18:52 -
download the software from only from the contact page – Dirty Bird Design Oct 26 '10 at 18:52
-
@Dirty I posted what I can tell you right now. As I said, you can strip the extension off if it works. Seeing as this is so difficult to do in .htaccess, maybe relying on the `MultiViews` option is a good idea for the moment – Pekka Oct 26 '10 at 18:53