Tags:
create new tag
view all tags

Question

Hi all. I currently have the script directory at the URL http://test.theoretic.com/bin, and the pub directory at the URL http://test.theoretic.com/pub. I'm wanting to try and get the URL for viewing of TWiki pages at http://test.theoretic.com/WEB/TOPIC, removing the bin/view part of the URL. I don't really care what the URLs are for editing and the pub directory, perhaps a subdirectory of and http://bin.theoretic.com and http://pub.theoretic.com. Can anyone think of any good way of doing this with Apache? I have root access and can modify my setup as needed. Thanks.

  • TWiki version: Beta Dec 10 2002
  • Perl version: 5.6.1
  • Web server & version: apache (recent)
  • Server OS: debian
  • Web browser & version:
  • Client OS:

-- AdamTheo - 21 Dec 2002

Answer

This was discussed at ShorterURLs, which includes some Apache mod_rewrite rules to do this.

-- RichardDonkin - 21 Dec 2002

Response

Hi, thanks. Tried it, but doesn't quite work yet. I've got a slightly different setup than what ShorterURLs assumes. For one, I don't have the wiki in a /twiki directory. My URLs are like http://test.theoretic.com/bin/view/WEB/TOPIC, not http://test.theoretic.com/twikibin/view/WEB/TOPIC. ShorterURLs uses this httpd.conf modification:

RewriteEngine on

# If we used a topic or web name, rewrite it into viewauth
RewriteCond %{REQUEST_FILENAME} !/twiki/
RewriteCond /home/rnapier/public_html/twiki/data%{REQUEST_FILENAME}.txt -f [OR]
RewriteCond /home/rnapier/public_html/twiki/data%{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /twiki/bin/viewauth$1

# If we used a script name, rewrite it into twiki/bin
RewriteCond %{REQUEST_FILENAME} !/twiki/
RewriteCond %{REQUEST_FILENAME} ^/([^/]+)/
RewriteCond /home/rnapier/public_html/twiki/bin/%1 -f
RewriteRule ^/[^/]+/(.*)$ /twiki/bin/%1/$1 [PT]

So by reading the mod_rewrite docs at http://httpd.apache.org/docs/mod/mod_rewrite.html I have tried various setups. The one that works the best (but still not right) is the following:

RewriteEngine on

RewriteLog /home/theoretic/test/rewrite_log
RewriteLogLevel 9

# If we used a topic or web name, rewrite it into viewauth
#RewriteCond %{REQUEST_FILENAME}
RewriteCond /home/theoretic/test/data%{REQUEST_FILENAME}.txt -f [OR]
RewriteCond /home/theoretic/test/data%{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /bin/viewauth$1

# If we used a script name, rewrite it into twiki/bin
RewriteCond %{REQUEST_FILENAME} ^/([^/]+)/
RewriteCond /home/theoretic/test/bin/%1 -f
RewriteRule ^/[^/]+/(.*)$ /bin/%1/$1 [PT]

I have also set the $scriptUrlPath variable in the TWiki.cfg file to "" (blank).

But it does not have the desired effect. When I enter the URL http://test.theoretic.com/Ransom/Home (for example) I get a 404. When I enter http://test.theoretic.com/view/Ransom, it works (showing me the Home page). When I enter http://test.theoretic.com/view/Ransom/Home (explicitly including the Home page in the URL) I get a "oopsnoweb" TWiki error at the URL http://test.theoretic.com/oops/Home/Home?template=oopsnoweb, saying the "Home" web does not exist.

I'm attempting to get my URLs to be http://test.theoretic.com/WEB/TOPIC. Any help here would be much appreciated.

The last few lines of my rewrite_log are this:

209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (2) init rewrite engine with requested uri /view/JabberAdvocacy/Home
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (3) applying pattern '^(.*)$' to uri '/view/JabberAdvocacy/Home'
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (4) RewriteCond: input='/home/theoretic/test/data/view/JabberAdvocacy/Home.txt' pattern='-f' => not-matched
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (4) RewriteCond: input='/home/theoretic/test/data/view/JabberAdvocacy/Home' pattern='-d' => not-matched
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (3) applying pattern '^/[^/]+/(.*)$' to uri '/view/JabberAdvocacy/Home'
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (4) RewriteCond: input='/view/JabberAdvocacy/Home' pattern='^/([^/]+)/' => matched
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (4) RewriteCond: input='/home/theoretic/test/bin/view' pattern='-f' => matched
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (2) rewrite /view/JabberAdvocacy/Home -> /bin/view/JabberAdvocacy/Home
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (2) forcing '/bin/view/JabberAdvocacy/Home' to get passed through to next API URI-to-filename handler
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (2) init rewrite engine with requested uri /JabberAdvocacy/Home
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (3) applying pattern '^(.*)$' to uri '/JabberAdvocacy/Home'
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (4) RewriteCond: input='/home/theoretic/test/data/JabberAdvocacy/Home.txt' pattern='-f' => matched
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (2) rewrite /JabberAdvocacy/Home -> /bin/viewauth/JabberAdvocacy/Home
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (3) applying pattern '^/[^/]+/(.*)$' to uri '/bin/viewauth/JabberAdvocacy/Home'
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (4) RewriteCond: input='/bin/viewauth/JabberAdvocacy/Home' pattern='^/([^/]+)/' => matched
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (4) RewriteCond: input='/home/theoretic/test/bin/bin' pattern='-f' => not-matched
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (2) local path result: /bin/viewauth/JabberAdvocacy/Home
209.26.25.155 - - [21/Dec/2002:12:01:16 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (1) go-ahead with /bin/viewauth/JabberAdvocacy/Home [OK]
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (2) init rewrite engine with requested uri /oops/Home/Home
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (3) applying pattern '^(.*)$' to uri '/oops/Home/Home'
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (4) RewriteCond: input='/home/theoretic/test/data/oops/Home/Home.txt' pattern='-f' => not-matched
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (4) RewriteCond: input='/home/theoretic/test/data/oops/Home/Home' pattern='-d' => not-matched
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (3) applying pattern '^/[^/]+/(.*)$' to uri '/oops/Home/Home'
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (4) RewriteCond: input='/oops/Home/Home' pattern='^/([^/]+)/' => matched
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (4) RewriteCond: input='/home/theoretic/test/bin/oops' pattern='-f' => matched
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (2) rewrite /oops/Home/Home -> /bin/oops/Home/Home
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#82436a4/initial] (2) forcing '/bin/oops/Home/Home' to get passed through to next API URI-to-filename handler
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (2) init rewrite engine with requested uri /Home/Home
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (3) applying pattern '^(.*)$' to uri '/Home/Home'
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (4) RewriteCond: input='/home/theoretic/test/data/Home/Home.txt' pattern='-f' => not-matched
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (4) RewriteCond: input='/home/theoretic/test/data/Home/Home' pattern='-d' => not-matched
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (3) applying pattern '^/[^/]+/(.*)$' to uri '/Home/Home'
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (4) RewriteCond: input='/Home/Home' pattern='^/([^/]+)/' => matched
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (4) RewriteCond: input='/home/theoretic/test/bin/Home' pattern='-f' => not-matched
209.26.25.155 - - [21/Dec/2002:12:01:20 -0600] [test.theoretic.com/sid#80bb7f4][rid#8215b14/subreq] (1) pass through /Home/Home

Thank you for your time.

-- AdamTheo - 21 Dec 2002

Result & Question

I have successfully got the httpd.conf change from ShorterURLs to work. I had to make one change for it to work, however: change the "viewauth" part to just "view". I am using beta Dec 10 2002, and it did not have a file or symlink called "viewauth", so Apache kept returning a error 404. I read in ShorterURLs that using just "view" is bad, because it can get into an infinite loop, but it does not say how to fix the problem of "viewauth" not actually existing. How is this done?

-- AdamTheo - 23 Dec 2002

Actually, I'll just move that last question to a new support topic, since the original question has been answered.

-- AdamTheo - 24 Dec 2002

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2006-07-18 - WillNorris
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.