Apache Rewrite Issue

467 views
Skip to first unread message

Dan Vega

unread,
Sep 14, 2010, 1:02:22 PM9/14/10
to framework-one
This is more of my lack of Rewrite knowledge than it is a FW/1 issue
but I thought I would post it here anyways. I am using some rules that
allow me to shorten my urls.

http://www.abc.com/index.cfm/blog/

becomes

http://www.abc.com/blog

thanks to

RewriteRule ^$ index.cfm [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [QSA,L]

This was working great until I added a sub system (admin) and came
across a couple issues. First off in my setupRequest method I have the
following code

if( request.subsystem == 'admin' ){
controller( 'admin:security.authorize' );
}

If the subsystem is admin we need to check permissions. Straight
forward enough but when I go to the url

http://dev.noahvega.org/index.cfm/admin:home/index

I get forwarded to

http://dev.noahvega.org/admin:security/login

Again, this is me really not understanding the power of apache rewrite
but I imagine there is a way to add this as a condition, I am just not
sure how to.


Next up my /admin folder is my admin subsystem. I want to make it easy
for the admins to get there so I thought I would put a redirect in
for

http://www.abc.com/admin -- > http://www.abc.com/index.cfm/admin:home/index

This works ..sort of.. The problem is it picks up admin: on the
redirect and causes other issues.
Redirect /admin /index.cfm/admin:

Can you say
forward /admin only not any variation of /admin:

** Again, sorry for the dumb, and maybe off topic questions but I am
stuck and figured someone else might have the same issues.

Thanks!

Dan Vega

unread,
Sep 14, 2010, 1:16:13 PM9/14/10
to framework-one
OOPs .. just noticed that it was not apache causing my first issue, it
was a fw/1 setting

SESOmitIndex = true,

So apparently It has issues with subsystems when that is turned on. I
will have to look further into that to see if I am doing something
wrong or if that is a bug.
> http://www.abc.com/admin-- >http://www.abc.com/index.cfm/admin:home/index

Dan Vega

unread,
Sep 14, 2010, 1:18:17 PM9/14/10
to framework-one
and now this works just fine..

Redirect /admin /index.cfm/admin:home/index


On Sep 14, 1:02 pm, Dan Vega <danv...@gmail.com> wrote:
> http://www.abc.com/admin-- >http://www.abc.com/index.cfm/admin:home/index

Dan Vega

unread,
Sep 14, 2010, 1:36:39 PM9/14/10
to framework-one
I spoke 2 soon, I don't think this is working

Redirect /admin /index.cfm/admin:home/index

I get redirected to the page but there is no style to it. Is this
causing issues with my stylesheet?

<link href="http://www.abc.com/admin/assets/css/login.css"
rel="stylesheet" type="text/css">



It redirects me to the page

Dan Vega

unread,
Sep 14, 2010, 2:26:59 PM9/14/10
to framework-one
took the easy way out..

sorry for the conversation with myself today ;)

# friendly url for administrator
Redirect /administrator /index.cfm/admin:home/index

Jamie Krug

unread,
Sep 14, 2010, 4:11:19 PM9/14/10
to framework-one
FWIW, instead of:
Redirect /admin /index.cfm/admin:home/index

You probably wanted something like this:
RewriteRule ^/admin(/)?$ /index.cfm/admin:home/index [R=301]

The $ in the match expression represents the ending anchor of the
request string. I also allow for an optional trailing slash there. The
[R=301] flag is for a permanent redirect. So, you use RewriteRule
instead of Redirect to get the power of regular expressions, but both
result in the same type of redirect.

Actually, this would do the same trick:
RedirectMatch 301 ^/admin(/)?$ /index.cfm/admin:home/index

You may also want to read the docs on the QSA flag for rewrites. You
don't need it in either case in your first example, though it
shouldn't cause any harm. It's a bit confusing, but basically, it's
only needed if you specify a query string in your RewriteRule's
substitution. It's best demonstrated by example--given a request of /
foo/?param=val consider these rules and the result of each...

RewriteRule ^/foo/$ /index.cfm
--> /index.cfm?param=val

RewriteRule ^/foo/$ /index.cfm?newparam=newval
--> /index.cfm?newparam=newval

RewriteRule ^/foo/$ /index.cfm?newparam=newval [QSA]
--> /index.cfm?param=val&newparam=newval

Notice the only time you lose the original query string is if you
explicitly specify a query string in your substitution and do not use
the QSA flag.

Cheers,
Jamie

Grant Powell

unread,
Mar 3, 2017, 9:32:47 AM3/3/17
to framework-one
Rewrite does not work. Getting generic ColdFusion 404 error page.

<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Users/.../www"
DirectoryIndex index.cfm
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

# exclude files from rewriting
RewriteCond %{REQUEST_FILENAME} !-f
# exclude directories from rewriting
RewriteCond %{REQUEST_FILENAME} !-d
# exclude static files
RewriteCond %{REQUEST_URI} !^.*\.(bmp|css|gif|htc|html?|ico|jpe?g|js|pdf|png|swf|txt|xml)$

# rewrite rules, NS skips rewrite rule for internal sub-requests
# for FW/1, removes index.cfm from the URL
RewriteRule ^(.*)$ /index.cfm/$1 [NS,L]

# sends 404 to the same action as onMissingView
ErrorDocument 404 /index.cfm?action=public:error.notfound
</VirtualHost>

Matt Quackenbush

unread,
Mar 3, 2017, 11:50:30 AM3/3/17
to framew...@googlegroups.com
Same as your other post today.
  1. You've replied to a nearly 7-year old thread.
  2. You've provided no context.
  3. Rewrite absolutely does work. It's been in use on hundreds of millions of sites for multiple decades.

https://groups.google.com/forum/#!topic/framework-one/ihpShgeYSQU



--
FW/1 documentation: http://framework-one.github.io
FW/1 source code: http://github.com/framework-one/fw1
FW/1 chat / support: https://gitter.im/framework-one/fw1
FW/1 mailing list: http://groups.google.com/group/framework-one
---
You received this message because you are subscribed to the Google Groups "framework-one" group.
To unsubscribe from this group and stop receiving emails from it, send an email to framework-one+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/framework-one.
For more options, visit https://groups.google.com/d/optout.

Andrew Myers

unread,
Mar 3, 2017, 4:10:48 PM3/3/17
to framew...@googlegroups.com
Hi Grant,

I notice in your config this line:

RewriteRule ^(.*)$ /index.cfm/$1 [NS,L]

To get ColdFusion to work with /index.cfm/* style requests, you need to modify the WEB-INF/web.xml in your coldfusion root directory, and add a mapping to forward those requests to the CFMServlet

Find the section that has:

   <servlet-mapping id="coldfusion_mapping_5">
        <servlet-name>CfmServlet</servlet-name>
        <url-pattern>*.cfml</url-pattern>
    </servlet-mapping>

And put this directly below it:

    <servlet-mapping id="coldfusion_mapping_1000">
        <servlet-name>CfmServlet</servlet-name>
        <url-pattern>/index.cfm/*</url-pattern>
    </servlet-mapping>

Restart CF and let us know if that works please?

Andrew.


On 4/03/2017 1:32 AM, Grant Powell wrote:
Reply all
Reply to author
Forward
0 new messages