Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Problem with CF9, Apache2 and aliases (mod_alias)

Guest
Aug 19, 2010 Aug 19, 2010

Hi

We're running ColdFusion9 with Apache 2 and want to access .cfm files without specifying any extensions. This used to work with CF5 (don't ask... ^^) and Apache1.3.x.

Here's a simple example with two aliases for accessing the administrator pages of ColdFusion:

Entries in httpd.conf:

    Alias /Admin        "/usr/local/httpd-2.2.16/htdocs/CFIDE/administrator/index.cfm"

    Alias /Admin.cfm    "/usr/local/httpd-2.2.16/htdocs/CFIDE/administrator/index.cfm"

When accessing the page with http://localhost/Admin.cfm, everything works fine.

When accessing the page with http://localhost/Admin though, we get 403 (Forbidden), and that's it.

It seems, that JRun looks at the extension of the original request (that is, before the alias mapping takes place) in order to find out whether it has to forward the request to the CF server or not. But we can't specify a nonexisting extension to the AddHandler-clause.

Is there any way make this work?

Using redirects instead of aliases works, but a redirect involves the client which is inacceptable since it would double the #requests.

Kind regards!

Daniel

1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 19, 2010 Aug 19, 2010
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 19, 2010 Aug 19, 2010

Hm.. your reply seems to be empty, mack_! I hope this doesn't mean that it's not possivle.

Regards

Daniel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 19, 2010 Aug 19, 2010

Let's trying again:

You can use mod_rewrite to rewrite the URL internally, without

generating an external redirect:

RewriteRule ^Admin$ Admin.cfm

--

Mack

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 19, 2010 Aug 19, 2010

Both mod_rewrite and mod_alias seem to have the same problem. They work with HTML or with PHP pages the way I'd expect. But with ColdFusion pages I get a Forbidden (403).

Regards

Daniel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 19, 2010 Aug 19, 2010

I'm using mod_rewrite with ColdFusion and PHP on quite a number of

sites and it works perfectly so I think there's something in your

setup that generates the 403 message. Does the user ColdFusion runs as

has read access to the files ?

--

Mack

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 19, 2010 Aug 19, 2010

Hi Mack

Yes, permissions and stuff should all be ok. Since aliasing/rewriting works like a charm, when using for example "Whatever.cfm" as an alias/rewrite for the CF admin, but without .cfm it doesn't work, it doesn't seem to be a permission problem.

I can't check at the moment but I've stumbled over the PT flag for the RewriteRule. Maybe you're using this flag? The documentation reads:

This flag forces the rewrite engine to set the uri field of the internal request_rec structure to the value of the filename field. This flag is just a hack to enable post-processing of the output of RewriteRule directives, using Alias, ScriptAlias, Redirect, and other directives from various URI-to-filename translators. For example, to rewrite /abc to /def using mod_rewrite, and then /def to /ghi usingmod_alias:

So maybe jrun.so behaves exactly like mod_alias and would still use /abc instead of /def, unless I'm specifing the PT flag. I will try that tomorrow...

Regards

Daniel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 20, 2010 Aug 20, 2010
Hi

Ok, it seems that using rewriting together with the PT (pass-through) flag really helps. I've added the following lines to httpd.conf:

     # mod_rewrite stuff
     RewriteEngine on
     RewriteCond %{REQUEST_URI}      ^([^.]*)$
     RewriteRule (.*)                $1.cfm  [PT]

     [...]

     # mod_alias stuff
     Alias /Admin.cfm    /usr/local/httpd-2.2.16/htdocs/CFIDE/administrator/index.cfm

Now the Login-Page for the ColdFusion Administrator pages show just fine.

Of course, this solution means that all requests that don't have an extension, will be handled as if the request had a .cfm extension, which could be a problem...

As a further step, it might be a good idea to use the RewriteMap directive, which would allow me to combine the .cfm and the aliasing in one place.

If you have any hints, ideas, they're more than welcome.

Kind Regards
Daniel
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 20, 2010 Aug 20, 2010

You want to specify each .cfm file in an Alias rule ? RewriteMap works

only for mod_rewrite, you would still need to specify the files twice,

once in the rewrite map file and once in the Alias rule.

Do you really need to alias indivirual files ? (aliasing whole

directories is much easier...)

--

Mack

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 20, 2010 Aug 20, 2010

At the moment (CF5) we have about 300 aliases of the form

   Alias /something   /some_path/some_other_path/something_else.cfm

This doesn't seem to work anymore under CF9, sind jrun22.so can't pass the request to ColdFusion anymore, since something doesn't have a .cfm extension. This is solved by my RewriteCond/RewriteRule stuff. Now I can use my 300 aliases again - with a slight change:

   Alias /something.cfm   /some_path/some_other_path/something_else.cfm

My point is now: I have to use mod_rewrite anyway because of the .cfm extension hack. So I might as well get rid of my aliases altogether and use the RewriteMap stuff instead, which seems to cover the same functionality as mod_alias.
Does that sound reasonable? (apart from the 300 aliases... which I can't change)
Regards
Daniel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 20, 2010 Aug 20, 2010

Forgot to answer your question... yes, I have to alias every single cfm page, since the alias and the path to the real cfm page doesn't have anything to do with each other.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 20, 2010 Aug 20, 2010
LATEST

I'm sure that you can do the same thing using only mod_rewrite only,

without using mod_alias (I'm doing something similar or a number of

sites).

Your solution with RewriteMap is a good one.

--

Mack

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources