You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Ben Fortuna <be...@gmail.com> on 2016/06/21 22:39:51 UTC

Response content type when url has no extension

Hi,

Just wondering what is the standard practice for managing sling requests
with no extension. My use case is that my index node is called 'index' so
when I get a request for just the domain name root (ie.
http://www.example.com/) it will redirect to my index but without an
extension (ie. /content/blah/index). The content type for this request is
text/plain, so the browser doesn't render the page.

Should this be handled in sling or is it common practice to use another
mechanism to redirect / to /index.html?

Many thanks.

Regards,
Ben

Re: Response content type when url has no extension

Posted by Ben Fortuna <be...@gmail.com>.
Hi all,

I ended up using Oliver's suggestion of the urlrewritefilter, which I
configured to redirect from the root path (i.e. /^/$/) to /index.html. Note
that this requires the Servicemix bundle version of the
org.tuckey.urlrewritefilter as the standard JAR doesn't included OSGi
metadata.

I did also see the configuration for default extensions in the Resource
Resolver Servlet (servletresolver.defaultExtensions), however it doesn't
seem to do what it says (unless I am misunderstanding the description).
This is set to html by default.

Many thanks for the suggestions.

regards,
ben


On Thu, Jun 23, 2016 at 2:42 AM, Oliver Lietz <ap...@oliverlietz.de> wrote:

> On Wednesday 22 June 2016 14:15:42 Bertrand Delacretaz wrote:
> > Hi,
> >
> > On Wed, Jun 22, 2016 at 12:39 AM, Ben Fortuna <be...@gmail.com>
> wrote:
> > > ...Should this be handled in sling or is it common practice to use
> another
> > > mechanism to redirect / to /index.html? ...
> >
> > I suspect people often use front-end rewriters like mod_rewrite to add
> > extensions to URLs which have none.
>
> Apache Sling URL Rewriter:
> https://github.com/apache/sling/tree/trunk/contrib/extensions/urlrewriter
>
> Regards,
> O.
>
> > Having a configurable default extension in Sling might be interesting,
> > but we'd probably need to limit it to specific paths, or make that
> > just an extension point.
> >
> > -Bertrand
>
>

Re: Response content type when url has no extension

Posted by Oliver Lietz <ap...@oliverlietz.de>.
On Wednesday 22 June 2016 14:15:42 Bertrand Delacretaz wrote:
> Hi,
> 
> On Wed, Jun 22, 2016 at 12:39 AM, Ben Fortuna <be...@gmail.com> wrote:
> > ...Should this be handled in sling or is it common practice to use another
> > mechanism to redirect / to /index.html? ...
> 
> I suspect people often use front-end rewriters like mod_rewrite to add
> extensions to URLs which have none.

Apache Sling URL Rewriter:
https://github.com/apache/sling/tree/trunk/contrib/extensions/urlrewriter

Regards,
O.

> Having a configurable default extension in Sling might be interesting,
> but we'd probably need to limit it to specific paths, or make that
> just an extension point.
> 
> -Bertrand


Re: Response content type when url has no extension

Posted by Robert Munteanu <ro...@apache.org>.
Hi Ben,

On Wed, 2016-06-22 at 08:39 +1000, Ben Fortuna wrote:
> Hi,
> 
> Just wondering what is the standard practice for managing sling
> requests
> with no extension. My use case is that my index node is called
> 'index' so
> when I get a request for just the domain name root (ie.
> http://www.example.com/) it will redirect to my index but without an
> extension (ie. /content/blah/index). The content type for this
> request is
> text/plain, so the browser doesn't render the page.
> 
> Should this be handled in sling or is it common practice to use
> another
> mechanism to redirect / to /index.html?

In the default Sling launchpad we use the following properties to set
up the redirect from the root page:

{
����"jcr:mixinTypes": [ "sling:Redirect" ],
����"sling:resourceType": "sling:redirect",
����"sling:target": "/index.html"
}

Perhaps you can do the same.

Thanks,

Robert

Re: Response content type when url has no extension

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Wed, Jun 22, 2016 at 4:19 PM, Jason Bailey <Ja...@sas.com> wrote:
> ...Under
> org.apache.sling.servlets.resolver
> for the property servletresolver.defaultExtensions ...

This is not for the use case discussed here, as explained in that
parameter's OSGi config description:

servletresolver.defaultExtensions.name = Default Extensions
servletresolver.defaultExtensions.description = The list of extensions
for which the default behavior \
 will be used. This means that the last path segment of the resource
type can be used as the script name.

So it's only meant to define which extensions use this "script name
can have resource name for extension FOO" logic, but still requires
the request to have an extension.

-Bertrand

RE: Response content type when url has no extension

Posted by Jason Bailey <Ja...@sas.com>.
I believe that exists, or I'm misunderstanding the intent. Under

org.apache.sling.servlets.resolver

for the property servletresolver.defaultExtensions

-----Original Message-----
From: Bertrand Delacretaz [mailto:bdelacretaz@apache.org] 
Sent: Wednesday, June 22, 2016 8:16 AM
To: users <us...@sling.apache.org>
Subject: Re: Response content type when url has no extension

Hi,

On Wed, Jun 22, 2016 at 12:39 AM, Ben Fortuna <be...@gmail.com> wrote:
> ...Should this be handled in sling or is it common practice to use 
> another mechanism to redirect / to /index.html? ...

I suspect people often use front-end rewriters like mod_rewrite to add extensions to URLs which have none.

Having a configurable default extension in Sling might be interesting, but we'd probably need to limit it to specific paths, or make that just an extension point.

-Bertrand

Re: Response content type when url has no extension

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Wed, Jun 22, 2016 at 12:39 AM, Ben Fortuna <be...@gmail.com> wrote:
> ...Should this be handled in sling or is it common practice to use another
> mechanism to redirect / to /index.html? ...

I suspect people often use front-end rewriters like mod_rewrite to add
extensions to URLs which have none.

Having a configurable default extension in Sling might be interesting,
but we'd probably need to limit it to specific paths, or make that
just an extension point.

-Bertrand