You are here: Foswiki>Tasks Web>Item14102 (31 Jan 2018, GeorgeClark)Edit Attach

Item14102: Documentation suggest a Short URL configuration (renaming view script to xview) which is no longer supported.

pencil
Priority: Normal
Current State: Closed
Released In: 2.1.3
Target Release: patch
Applies To: Engine
Component:
Branches: Release02x01 master Item13897 Item14380 Item14537
Reported By: VickiBrown
Waiting For:
Last Change By: GeorgeClark
This Task INCLUDEs Support/Question1787. Given that the only change I made was to upgrade from FW 1.1.9 to FW 2.1.2, I'm blaming something in FW until I get a better answer.

Foswiki 1.1.9

I have a Foswiki 1.1.9 installation working with short URLs (no /bin/view) on Dreamhost. (http://baaptfwi119.dreamhosters.com/)

It is using Short URL code from Support/ShorterUrlCookbook in the top level .htaccess file.

RewriteEngine On
RewriteBase /             
RewriteRule ^([^/.]+)$ /bin/xview/Main/$1                      [L,NE]
RewriteRule ^Main/([^/.]+)$ http://baaptfwi119.dreamhosters.com/$1                   [L,NE]
RewriteRule ^(Sandbox|System|Trash|TWiki|Drafts)/(.*?)$ /bin/xview/$1/$2    [L,NE]
# Special rule for Main
RewriteRule ^bin/view/Main/([^/.]+)$ http://baaptfwi119.dreamhosters.com/$1             [L,NE]
RewriteRule ^bin/view$ http://baaptfwi119.dreamhosters.com/                         [L,NE]

# do not skip index.html - instead we are using a static (quickly loading) file
RewriteRule ^$ /bin/xview/Main/                              [L,NE]

For Foswiki 1.1.9, this works.

Foswiki 2.1.2

I upgraded the FW installation to 2.1.2. (http://baapt.dreamhosters.com/bin/view/Main)

If I try to use the short URLs (e.g. http://baapt.dreamhosters.com), I get an error:
The requested URL / was not found on this server.

The only differences in the .htaccess file are in the hostname portion of the URL:

diff baapt_foswiki/.htaccess baapt_foswiki119/.htaccess
10c10
< RewriteRule ^Main/([^/.]+)$ http://baapt.dreamhosters.com/$1                   [L,NE]
---
> RewriteRule ^Main/([^/.]+)$ http://baaptfwi119.dreamhosters.com/$1                   [L,NE]
13,14c13,14
< RewriteRule ^bin/view/Main/([^/.]+)$ http://baapt.dreamhosters.com/$1             [L,NE]
< RewriteRule ^bin/view$ http://baapt.dreamhosters.com/                         [L,NE]
---
> RewriteRule ^bin/view/Main/([^/.]+)$ http://baaptfwi119.dreamhosters.com/$1             [L,NE]
> RewriteRule ^bin/view$ http://baaptfwi119.dreamhosters.com/                         [L,NE]

The only other change is from FW 1.1.9 to FW 2.1.2

When I turn off the "short URL" code, everything works as expected.

Given that the only difference I can see is in the Foswiki underpinnings, I am blaming this on FW unless someone can give me a very good reason to blame something else.

-- VickiBrown - 16 Jun 2016

Vicki, do you have any idea why the view script has been copied to xview? Foswiki 2.x uses the recovered script name as the "action", and Foswiki has no idea what an "xview" is.

I don't have access to dreamhost or even a web server configured with .htaccess, but I was able to make the "xview" script to work by hardcoding the action.
--- bin/view    2016-06-28 22:05:09.158922345 -0400
+++ bin/xview   2016-06-29 22:40:38.362872849 -0400
@@ -20,7 +20,7 @@
     my $setlib = File::Spec->catpath( $volume, $binDir, 'setlib.cfg' );
     @INC = ( '.', grep { $_ ne '.' } @INC ) unless $binDir;
     require $setlib;
-    $action =~ s/\..*$//;    # Remove eventual file extension
+    $action = 'view';
     $ENV{FOSWIKI_ACTION} = $action;
 }
 

-- GeorgeClark - 30 Jun 2016

As per Support/ShorterUrlCookbook Option 2a: Complete example as .htaccess:

The file bin/xview is a copy of bin/view. For this specific site, Main web is the main public web with a special "root" url: http://site.com/WebHome will access http://site.com/bin/view/Main/WebHome.

If you look carefully at the htaccess code, I'd say that the copy of view as xview is there to prevent a redirect loop.

RewriteRule ^([^/.]+)$ /bin/xview/Main/$1
...
RewriteRule ^bin/view/Main/([^/.]+)$... http://x.y.com$1...
RewriteRule ^bin/view/$... http://x.y.com/  ...         
RewriteRule ^$ /bin/xview/Main/ .     

Tasks/Item14102 filed. Design by Omniscience is wrong.

-- VickiBrown - 01 Jul 2016

So... I ended up editing xview
    # $action =~ s/\..*$//;    # Remove eventual file extension
    $action = 'view';

and using this .htaccess file
  # This enables access to the documents in the Foswiki root directory
      Order Allow,Deny
      Allow from all
      Deny from env=blockAccess

Options +FollowSymLinks 
RewriteEngine On
RewriteBase /             

RewriteRule ^([^/.]+)$ /bin/xview/BAAPT/$1                      [L,NE]
RewriteRule ^(BAAPT|Main|Sandbox|System|Trash|TWiki|Drafts)/(.*?)$ /bin/xview/$1/$2    [L,NE]
# Special rule for BAAPT
RewriteRule ^bin/view/BAAPT/([^/.]+)$ http://wiki.baapt.org/$1             [L,NE]
RewriteRule ^bin/view$ http://wiki.baapt.org/                         [L,NE]

# do not skip index.html - instead we are using a static (quickly loading) file
RewriteRule ^$ /bin/xview/BAAPT/                              [L,NE]

I decided to use Main as a Foswiki-typical web; that is, it's %USERWEB% and doesn't contain very much local data other than users and groups and shared preferences. My primary data web is BAAPT, and the unmodified URL (http://wiki.baapt.org) goes there.

I also decided that I didn't like removing the web name (something the cookbook was suggesting). That is, I did not try to support:
http://site.com/WEB/WebHome             => http://site.com/WebHome

This made the whole process easier.

-- VickiBrown - 07 Oct 2016

+1. Eliminating the web name is very non-standard. I never had heard of that until you pointed it out. It would probably be best to change the ShorterUrlCookbook to drop that recommendation.

-- GeorgeClark - 07 Oct 2016
 

-- VickiBrown - 29 Jun 2016

 

ItemTemplate edit

Summary Documentation suggest a Short URL configuration (renaming view script to xview) which is no longer supported.
ReportedBy VickiBrown
Codebase 2.1.2, 2.1.1, 2.1.0, 2.1.0 beta1, 2.0.3, 2.0.2, 2.0.1, 2.0.0
SVN Range
AppliesTo Engine
Component
Priority Normal
CurrentState Closed
WaitingFor
Checkins distro:713c70bb32bf distro:e85804987ba4
TargetRelease patch
ReleasedIn 2.1.3
CheckinsOnBranches Release02x01 master Item13897 Item14380 Item14537
trunkCheckins
masterCheckins distro:713c70bb32bf distro:e85804987ba4
ItemBranchCheckins distro:713c70bb32bf distro:e85804987ba4
Release02x01Checkins distro:713c70bb32bf
Release02x00Checkins
Release01x01Checkins
Topic revision: r7 - 31 Jan 2018, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy