beppu wrote:
> I was watching my access logs today, and I saw someone come in to one
> of my sites from google and then try to guess a URL based on
> hierarchy.
>
> He did something like this:
>
> GET /foo/bar/baz => 200
> GET /foo/bar/ => 404!
>
> The problem with the second request was that he put a trailing slash
> at the end, but the controller that he wanted matches a very similar
> path that DOES NOT have the trailing slash. So then he received an
> uninformative 404 response which prompted him to leave my site
>
> To prevent this from happening in the future, I came up with this
> simple controller:
>
> C(
> EndsWithSlash => [ '/(.*)/' ],
>
this allows paths like this "//" .. maybe it should be /(.+)/
I looked in REgexp::Common and did not find a path regexp
<http://search.cpan.org/~abigail/Regexp-Common-2.122/lib/Regexp/Common/URI.pm>
> get => sub {
> my ($self, $path) = @_;
> $self->redirect("/$path", 301);
> }
> ),
>
> This is a controller you can put towards the end of your controller
> list, and it'll catch URLs that end with '/' and perform a 301
> redirect to a version of the URL that doesn't end with '/'.
>
Well the DOCUMENT_ROOT feature of apache would catch a URL with / and
try to find index.html in that directory.
Perhaps that should be option 1?
I have the same issue with the unix comamnd cp --archive
if you put a trailing slash on the end you get one behavior, otherwise
you get another.
beppu wrote:
> One sec... I didn't read your response carefully enough before I
> responded.
>
> We're both talking about mod_dir-related features, but you were
> thinking of DirectoryIndex while I was thinking of DirectorySlash.
>
ah yes!
> Neither can really solve my problem, because I'm trying to *remove*
> something from the URL,
>
i think you are over idiot-proofing your site and in the process, you
are making it counter-intuitive.
the mapping between path syntax and behavior is becoming less
straightforward now.
it's kind of like the mess were are in with HTML because the web browser
people came up with
permissive parsers.