Discussion:
make apache accepts URL without file extensions
(too old to reply)
j***@gmail.com
2013-07-03 16:00:58 UTC
Permalink
This is embarrassing - I made it work and I cannot reproduce on another server:

I set up my current RHEL site with apache 2.2.13 a couple years ago to have it accept URLs that their file extensions (.php, .html) can be omitted. i.e. The browser stays on the URL without showing the file extension. e.g.
http://mydomain.org/test for
http://mydomain.org/test.php
It works just as fine for the entire site over the years, and is still working.
- I didn't use RewriteEngine (as a test if I try to turn it on it fails to load mod_rewrite.so because I never had one);
- I never use .htaccess

Now the problem is when we need to move to a new machine I can not make it work on RHEL/apache 2.4.4 -- I cannot figure out from my current settings how I got it work. I tried to use the old httpd.conf it simply didni't work... and *many* of the cross reference hyperlinks in site pages or URL broadcasted to world are all without file extensions.

Any suggestion where else should I look?

Many thanks in advance! joe
Luuk
2013-07-04 15:21:00 UTC
Permalink
Post by j***@gmail.com
I set up my current RHEL site with apache 2.2.13 a couple years ago to have it accept URLs that their file extensions (.php, .html) can be omitted. i.e. The browser stays on the URL without showing the file extension. e.g.
http://mydomain.org/test for
http://mydomain.org/test.php
It works just as fine for the entire site over the years, and is still working.
- I didn't use RewriteEngine (as a test if I try to turn it on it fails to load mod_rewrite.so because I never had one);
- I never use .htaccess
Now the problem is when we need to move to a new machine I can not make it work on RHEL/apache 2.4.4 -- I cannot figure out from my current settings how I got it work. I tried to use the old httpd.conf it simply didni't work... and *many* of the cross reference hyperlinks in site pages or URL broadcasted to world are all without file extensions.
Any suggestion where else should I look?
Many thanks in advance! joe
In my config i find like like this:
<FilesMatch "\.ph(p[345]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.php[345]?s$">
SetHandler application/x-httpd-php-source
</FilesMatch>


I think your config has somehting like this?:
<FilesMatch "*">
SetHandler application/x-httpd-php
</FilesMatch>
Lewis
2013-07-05 03:46:55 UTC
Permalink
Post by Luuk
Post by j***@gmail.com
I set up my current RHEL site with apache 2.2.13 a couple years ago to have it accept URLs that their file extensions (.php, .html) can be omitted. i.e. The browser stays on the URL without showing the file extension. e.g.
http://mydomain.org/test for
http://mydomain.org/test.php
It works just as fine for the entire site over the years, and is still working.
- I didn't use RewriteEngine (as a test if I try to turn it on it fails to load mod_rewrite.so because I never had one);
- I never use .htaccess
Now the problem is when we need to move to a new machine I can not make it work on RHEL/apache 2.4.4 -- I cannot figure out from my current settings how I got it work. I tried to use the old httpd.conf it simply didni't work... and *many* of the cross reference hyperlinks in site pages or URL broadcasted to world are all without file extensions.
Any suggestion where else should I look?
Many thanks in advance! joe
<FilesMatch "\.ph(p[345]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.php[345]?s$">
SetHandler application/x-httpd-php-source
</FilesMatch>
<FilesMatch "*">
SetHandler application/x-httpd-php
</FilesMatch>
That seems like a spectacularly bad idea.
--
I laugh in the face of danger. Then I hide until it goes away.
patpro ~ patrick proniewski
2013-07-05 05:38:35 UTC
Permalink
Post by Lewis
Post by Luuk
Post by j***@gmail.com
I set up my current RHEL site with apache 2.2.13 a couple years ago to
have it accept URLs that their file extensions (.php, .html) can be
omitted. i.e. The browser stays on the URL without showing the file
extension. e.g.
http://mydomain.org/test for
http://mydomain.org/test.php
It works just as fine for the entire site over the years, and is still working.
- I didn't use RewriteEngine (as a test if I try to turn it on it fails to
load mod_rewrite.so because I never had one);
- I never use .htaccess
Now the problem is when we need to move to a new machine I can not make it
work on RHEL/apache 2.4.4 -- I cannot figure out from my current settings
how I got it work. I tried to use the old httpd.conf it simply didni't
work... and *many* of the cross reference hyperlinks in site pages or URL
broadcasted to world are all without file extensions.
Any suggestion where else should I look?
Many thanks in advance! joe
<FilesMatch "\.ph(p[345]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.php[345]?s$">
SetHandler application/x-httpd-php-source
</FilesMatch>
<FilesMatch "*">
SetHandler application/x-httpd-php
</FilesMatch>
That seems like a spectacularly bad idea.
Yes, it is a terrible idea.

I think what the OP is looking for is Multiview:

<Directory foo>
Options +Multiviews
</Directory

-> if you GET http://example.com/foo/file and if "/foo/file" does not
exist, Apache will look for "/foo/file.*" (serving "/foo/file.php" if it
exists).

rtfm: http://httpd.apache.org/docs/2.4/content-negotiation.html
--
photo http://photo.patpro.net/
blog http://www.patpro.net/
Luuk
2013-07-05 17:33:05 UTC
Permalink
Post by patpro ~ patrick proniewski
Post by Lewis
Post by Luuk
Post by j***@gmail.com
I set up my current RHEL site with apache 2.2.13 a couple years ago to
have it accept URLs that their file extensions (.php, .html) can be
omitted. i.e. The browser stays on the URL without showing the file
extension. e.g.
http://mydomain.org/test for
http://mydomain.org/test.php
It works just as fine for the entire site over the years, and is still working.
- I didn't use RewriteEngine (as a test if I try to turn it on it fails to
load mod_rewrite.so because I never had one);
- I never use .htaccess
Now the problem is when we need to move to a new machine I can not make it
work on RHEL/apache 2.4.4 -- I cannot figure out from my current settings
how I got it work. I tried to use the old httpd.conf it simply didni't
work... and *many* of the cross reference hyperlinks in site pages or URL
broadcasted to world are all without file extensions.
Any suggestion where else should I look?
Many thanks in advance! joe
<FilesMatch "\.ph(p[345]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.php[345]?s$">
SetHandler application/x-httpd-php-source
</FilesMatch>
<FilesMatch "*">
SetHandler application/x-httpd-php
</FilesMatch>
That seems like a spectacularly bad idea.
Yes, it is a terrible idea.
<Directory foo>
Options +Multiviews
</Directory
-> if you GET http://example.com/foo/file and if "/foo/file" does not
exist, Apache will look for "/foo/file.*" (serving "/foo/file.php" if it
exists).
rtfm: http://httpd.apache.org/docs/2.4/content-negotiation.html
You are, of course, right .... ;)
j***@gmail.com
2013-07-07 21:23:18 UTC
Permalink
Post by Luuk
Post by patpro ~ patrick proniewski
<Directory foo>
Options +Multiviews
</Directory
if you GET http://example.com/foo/file and if "/foo/file" does not
exist, Apache will look for "/foo/file.*" (serving "/foo/file.php" if it
exists).
rtfm: http://httpd.apache.org/docs/2.4/content-negotiation.html
You are, of course, right .... ;)
Yes this sounds like "Multiviews" plays the trick.
I repeated it with apache-2.2.24, but not so on apache-4.4
At least I got something to work. Thank you all!
--joe
Luuk
2013-07-08 18:03:18 UTC
Permalink
Post by j***@gmail.com
Post by Luuk
Post by patpro ~ patrick proniewski
<Directory foo>
Options +Multiviews
</Directory
if you GET http://example.com/foo/file and if "/foo/file" does not
exist, Apache will look for "/foo/file.*" (serving "/foo/file.php" if it
exists).
rtfm: http://httpd.apache.org/docs/2.4/content-negotiation.html
You are, of course, right .... ;)
Yes this sounds like "Multiviews" plays the trick.
I repeated it with apache-2.2.24, but not so on apache-4.4
At least I got something to work. Thank you all!
I see some notes about MulitViews in the changelog* of 2.4.4
Maybe these hase something to do with your problem.

*(http://www.apache.org/dist/httpd/CHANGES_2.4)
Lewis
2013-07-10 07:29:07 UTC
Permalink
Post by Luuk
Post by j***@gmail.com
Post by Luuk
Post by patpro ~ patrick proniewski
<Directory foo>
Options +Multiviews
</Directory
if you GET http://example.com/foo/file and if "/foo/file" does not
exist, Apache will look for "/foo/file.*" (serving "/foo/file.php" if it
exists).
rtfm: http://httpd.apache.org/docs/2.4/content-negotiation.html
You are, of course, right .... ;)
Yes this sounds like "Multiviews" plays the trick.
I repeated it with apache-2.2.24, but not so on apache-4.4
At least I got something to work. Thank you all!
I see some notes about MulitViews in the changelog* of 2.4.4
Maybe these hase something to do with your problem.
*(http://www.apache.org/dist/httpd/CHANGES_2.4)
Speaking of Apache-2.4.4, does anyone know why it's not in FreeBSD Ports?
--
Reality is a curve. That's not the problem. The problem is that there
isn't as much as there should be. According to some of the more mystical
texts in the stacks of the library of Unseen University - (...) - at
least nine-tenths of all the original reality ever created lies outside
the multiverse, and since the multiverse by definition includes
absolutely everything that is anything, this puts a bit of a strain on
things. --Moving Pictures
patpro ~ patrick proniewski
2013-07-10 16:48:17 UTC
Permalink
Post by Lewis
Speaking of Apache-2.4.4, does anyone know why it's not in FreeBSD Ports?
because your port tree is not up to date, maybe?

$ grep ^PORTVERSION /usr/ports/www/apache24/Makefile
PORTVERSION= 2.4.4


patpro
--
photo http://photo.patpro.net/
blog http://www.patpro.net/
Lewis
2013-07-10 21:26:16 UTC
Permalink
Post by patpro ~ patrick proniewski
Post by Lewis
Speaking of Apache-2.4.4, does anyone know why it's not in FreeBSD Ports?
because your port tree is not up to date, maybe?
Hmm. It is though. I run portsnap cron and portsnap update nightly. I
don't have a apache24 directory in www.

# ls -lsd apache*
4 drwxr-xr-x 3 root wheel 512 Feb 24 2012 apache-forrest
4 drwxr-xr-x 2 root wheel 512 Feb 24 2012 apache-mode.el
4 drwxr-xr-x 3 root wheel 512 Jun 27 22:58 apache22
4 drwxr-xr-x 2 root wheel 512 Nov 9 2012 apache22-event-mpm
4 drwxr-xr-x 2 root wheel 512 Nov 9 2012 apache22-itk-mpm
4 drwxr-xr-x 3 root wheel 512 Nov 9 2012 apache22-peruser-mpm
4 drwxr-xr-x 2 root wheel 512 Nov 9 2012 apache22-worker-mpm
Post by patpro ~ patrick proniewski
$ grep ^PORTVERSION /usr/ports/www/apache24/Makefile
PORTVERSION= 2.4.4
I know it was not in for quite a while. Guess I'll have to look into why
portsnap's cron tasks are not firing correctly.

Running portsnap fetch now and will see what happens.

Thanks.
--
'You have the right to remain silent,' he [Carrot] said. 'You have the
right not to injure yourself falling down the steps on the way to the
cells. You have the right not to jump out of high windows. You do not
have to say anything, you see, but anything you do say, well, I have to
take it down and it might be used as evidence.' --Guards! Guards!
Continue reading on narkive:
Loading...