Tags:
create new tag
view all tags

Question

ShorterCaseInsensitiveURLs describes a great little enhancement, but it's using the httpd.conf file that isn't editable on hosted domains.

Is there a way to achieve the same thing by editing the .htaccess file instead?

Environment

TWiki version: TWikiRelease01Feb2003
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Some linux, probably Red Hat
Web server: Apache 1.3
Perl version: Perl 5.6.1
Client OS: Win XP
Web Browser: IE 6, Mozilla 1.5

http://g-b.dk/bin/view/Main/WebHome

-- TorbenGB - 25 Sep 2003

Answer

You can try any httpd.conf commands in .htaccess - despite the latter's name, it's really a 'mini-httpd.conf' for the directory in which it's located. Your webhost may well have Apache settings that prevent this sort of URL rewriting, but it can't hurt to try it out (maybe on a test installation of TWiki if you want your main TWiki to stay available - mod_rewrite can be quite hairy to get right).

-- RichardDonkin - 29 Sep 2003

I might be willing to give it a try since I'm in the process of setting up a new hosted twiki. I am concerned about the possible performance hit from implementing url rewriting through .htaccess as mentioned in ShorterURLs. I guess the only way to find out is to give it a try.

-- LynnwoodBrown - 29 Sep 2003

The apache docs state which directives work in which context (e.g. httpd.conf, .htaccess, etc.). Unfortunately ScriptAlias is not available for the .htaccess context. I tried it anyway on freeshell.org but it didn't work. : (

Redirect does work in .htaccess but in my experiments to date I have not been able to get it to work. Maybe you'll have better luck (please? {grin})

-- MattWilkie - 01 Oct 2003

Thanks for your attempts, folks. Seems I'll have to live with the regular URLs.

-- TorbenGB - 04 Nov 2003

Dreamhost (see DreamhostSetupNotes) have just added a new feature that seems to be based on Apache rewrite and is accessible to normal users - check the newsletters on their support site, it's in the latest one. Not sure if this is flexible enough or how it's implemented, but it's worth a try.

Dreamhost already implement subdomains, which could be useful for certain things sucha as MyTWikiOrg with some coding, though not shorter URLs.

-- RichardDonkin - 05 Nov 2003

Success!

It was elegantly simple to achieve the first major step (thanks to Mark):

RewriteEngine On
# if URL after "g-b.dk" begins with an uppercase letter then it's a TWiki web,
# so internally prefix it with "/bin/view/":
RewriteRule ^([A-Z].*) /bin/view/$1

This achieves that we can always skip typing the /bin/view part of the URL: http://g-b.dk/Main/TorbenGB now works!

Facts:


Awesome! Thanks Torben and Mark!

-- MattWilkie - 17 Sep 2004

I don't know if this has been said before but:

Case insensitive URLs would be much safer to implement if you could better guaranty that the case insensitive names of webs & topics were unique. The easiest way to do this would be to make the checks in the edit, save, rename and web manage scripts (have I missed any?) for topic/web already existing to be case insensitive. So if you go to edit or save HostedShorterCaseInsensitiveUrls it would automatically redirect to this topic HostedShorterCaseInsensitiveURLs and if you were using the onlynewtopic flag it would redirect to the oopscreatenewtopic page.

There may be instances were the differing capitalisation for topic names might produce different meanings but I can't think of any offhand. It will be a problem when upgrading for instalations where this has already happened. Perhaps it could view one topic but display a message saying what the other topics were and provide links directly to the rename page for each topic.

-- SamHasler - 17 Sep 2004

I tried using this simple and (until now) quite satisfactory little enhancement on a TWiki 4.0.4 installation and it prevented all style sheets from loading. Oddly, I compared the html source for a particular page with the rewrite rule turned on and off and the source was identical - and yet, the style sheets did not load with the rewrite rule enabled. Anyone seen this or have any suggestions what might be causing this?

-- LynnwoodBrown - 18 Aug 2006

Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2006-08-18 - LynnwoodBrown
 
  • 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.