Manual talk:Short URL/Archive 1
Note Talk page originally from m:Talk:Using a very short URL
Apache 1.3.x
editThe host on which my wiki is served is using Apache 1.3.x. Does anyone have a solution that works on older versions of Apache? I tried this one and it didn't work. I ended up with 404 errors.
Thanks!
Kerim Friedman 9 July 2005 13:02 (UTC)
- As far as I know, the "kludge" solution should sort of work with Apache 1.3. I have 2 suggestions for you:
- Make sure you have done all of the modifications. There are 4 files to modify.
- In httpd.conf, specify a filename in RewriteLog and set RewriteLogLevel to 5 or so, so you can find out exactly what file the server was finally looking for.
- I'm afraid I can't remember all of the little issues that cropped up as I was trying to perfect this setup with Apache 1.3; I just got fed up enough that it was simpler to go ahead and switch to Apache 2. Also, I haven't been able to find a patch to fix the ampescape problem in Apache 1.3, and there might not even be one. You should consider moving to Apache 2. --Yath 09:10, 10 July 2005 (UTC)
I had issues with search with very short urls on the following:
- Windows Server 2003
- Apache 2.0.54
- MySQL 4.0.25
- PHP 5.0.4
- MediaWiki 1.4.5
URLs were coming in like below and not working because the search querystring parameter would never acknowledge it contained data:
/Special:Search?search=apache&fulltext=Search
What needed to come in is:
/index.php/Special:Search?search=apache&fulltext=Search
The resolution was to edit getSearchLink() in Skin.php and change the following:
From: return $searchPage->getLocalURL(); To: return '/index.php'.$searchPage->getLocalURL();
I know that this isn't the grand solution to solve it for all scenarios, but it works for us for the time being.
- You said that what needed to come in was "/index.php/...". Does that mean the url in the browser was
"http://site.tld/index.php/Special:Search?search=apache&fulltext=Search"
? Because that isn't the goal of this setup. --Yath 21:51, 14 July 2005 (UTC)
works fine with apache 1.3.33
editI'm running a few MediaWiki sites (like [1] ) From the very beginning I've been putting the wiki in / not /wiki/ which makes more sense in my POV. This works with Debian Sarge, Apache 1.3.33, and the following redirect rules and settings in /etc/apache/conf.d/sitename (see below)
If you want other stuff to be available then add more directories to the exception of the rewriting url for example: (RewriteCond %{REQUEST_URI} !^/(stylesheets|images|skins|downloads|)/ ) and put whatever you want into that subdirectories. This works fine for i.e. a download-directory. If you have other complex php application it might be a problem (I don't know), but on an average MediaWiki Site I like it better like this!
#/etc/apache/conf.d/sitename # replace sitename with.your.domain.org <VirtualHost 195.xxx.yyy.zzz> ServerName sitename DocumentRoot /home/www/webspace/sitename CustomLog /var/log/apache/sitename-access.log combined ErrorLog /var/log/apache/sitename-error.log # Allow wiki articles to start with a period <Files .*> Order Deny,Allow Allow From All </Files> #rewrites #1.3.* Note: With later versions, one may use index.php/$1 instead of #wiki.phtml?title=$1 , and currently wiki.phtml exists only to include #index.php and add compatiblity with old documentation. RewriteEngine On # Don't rewrite requests for files in MediaWiki subdirectories, # MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt #add "|config" for the setup-routine in the line below, after skins RewriteCond %{REQUEST_URI} !^/(stylesheets|images|skins)/ RewriteCond %{REQUEST_URI} !^/(redirect|texvc|index).php RewriteCond %{REQUEST_URI} !^/error/(40(1|3|4)|500).html RewriteCond %{REQUEST_URI} !^/favicon.ico RewriteCond %{REQUEST_URI} !^/robots.txt RewriteRule ^/(.*)$ /index.php/$1 [L,QSA] # close the php security hole... php_flag register_globals off </VirtualHost> <Directory /home/www/webspace/sitename/images/> AllowOverride None AddType text/plain .html .htm .shtml php_admin_flag engine off Options None php_flag engine off </Directory> <Directory /home/www/webspace/sitename/stylesheets/> AllowOverride None AddType text/plain .html .htm .shtml php_admin_flag engine off </Directory> # any security issues in here?
Please give some feedback or let me know if this should be added to the page itself?
Epe 21:51, 27 July 2005 (UTC)
Other way...
editHi, there is another way to get a really short URI
Server version: Apache/2.0.54
<VirtualHost *:80> ServerAdmin RedHand.pl@gmail.com ServerName wiki.szluug.org # ignore warnings! it works :] DocumentRoot /home/wiki/index.php Alias /wiki /home/wiki <Directory /home/wiki> Options Indexes FollowSymLinks AllowOverride None Order Allow,Deny Allow from all </Directory> </VirtualHost>
How to hide Main_Page?
editHi! I've managed to configure my wiki to http://www.foo.com/wiki/article, and I'm happy with this in all instances but one: I want to have http://www.foo.com instead of http://www.foo.com/wiki/Main_Page. Is it possible?
- iFrame is the only thing I can think og -- ℑilver§ℑide 08:27, 8 January 2006 (UTC)
Simple solution without the need to patch anything?
editI don't know why many people are saying that you need to patch Apache and/or MediaWiki. I'm running a Wiki with a "very short URL" since version 1.3.x without any patch to Apache or MediaWiki. My robots.txt also keeps crawlers from crawling unnecessary pages. Maybe I'm blind and don't see an obvious problem, but I never heard a complaint from a user. You can see the Wiki in action here: http://wiki.winf.at/
I've put the MediaWiki source into the subdirectory /w/ of the VirtualHost's root. Here is a snippet of my Apache (1.3.x) configuration:
<VirtualHost *> ServerName wiki.winf.at DocumentRoot /path/to/winfwiki RewriteEngine On RewriteRule ^/COPYING$ /w/COPYING [L] RewriteCond %{REQUEST_URI} !^/w/ RewriteCond %{REQUEST_URI} !^/(robots\.txt|favicon\.ico|winfwiki\.png) RewriteRule ^/(.*)$ /w/index.php/$1 [L,QSA] <Directory "/path/to/winfwiki/w/images"> AddType application/x-httpd-php-source .php .phps .php3 </Directory> php_admin_value register_globals 0 </VirtualHost>
Here the relevant part of the MediaWiki LocalSettings.php:
$IP = "/path/to/winfwiki/w"; $wgScriptPath = "/w"; $wgScript = "$wgScriptPath/index.php"; $wgRedirectScript = "$wgScriptPath/redirect.php"; $wgArticlePath = "/$1"; $wgStylePath = "$wgScriptPath/skins"; $wgStyleDirectory = "$IP/skins"; $wgLogo = "/winfwiki.png"; $wgUploadPath = "$wgScriptPath/images"; $wgUploadDirectory = "$IP/images";
Please tell me if you see a problem with my configuration, because I don't understand why many people keep saying that it's "dangrous" to have the article names at the root path.
62.178.39.193 17:35, 12 November 2005 (UTC)
- Instead of editing the apache config file you can also put an .htaccess file with the following code in your subdomain root:
RewriteEngine On RewriteRule ^/COPYING$ /w/COPYING [L] RewriteCond %{REQUEST_URI} !^/w/ RewriteCond %{REQUEST_URI} !^/(robots\.txt|favicon\.ico|winfwiki\.png) RewriteRule ^(.*)$ /w/index.php/$1 [L,QSA] php_admin_value register_globals 0
- Hope this helps --62.251.90.73 02:35, 30 December 2005 (UTC)
- This (.htaccess) version gives me an error:
php_admin_value not allowed here
- It was intented to be placed into your httpd.conf/per-srever context. In per-dir context, use
php_flag register_globals 0
- instead. It'll only have an impact, if PHP runs as a module (and not in cgi mode) --Caterham 21:38, 14 April 2006 (UTC)
Mess
editWell I don't really know anything solid about what works and what doesn't, or where there are security implications, but I do know that this page is mess at the moment. I'd read the page a few months back, and I just advised a friend to take a look at it. He came back to me confused, which is not surprising. eeeugh! what happened? In fact this talk page is tidier and more useful than the article itself. Can we not arrive at a concensus on the best approaches (split by apache/mediawiki versions if necessary)? -- Harry Wood 15:31, 18 November 2005 (UTC)
Help? *bursts out crying or Ampersand shpampersand!
editSo, I have tried everything backwards and forwards and in-between and even all kinds of combinations of the various methods mentioned here and elsewhere, and *NOTHING I CAN DO* will make ampersands in page titles work!!! Here are the various .htaccess files I have tried and failed with, and their exact outcome:
Ex. 1
editRewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?title=$1 [L,QSA]
This one is the original one I used until I found it couldn't parse ampersands. Period. Trying http://mydomain.tld/wiki/Testing_&_testing_Some_More merely loads the page at Testing_, with everything after the ampersand dying.
Ex. 2
edit# enable the rewriter RewriteEngine on # anything that contains a dot is to be left alone. RewriteRule \. - [L] # anything else is to be treated as a title RewriteRule ^(.+)$ /index.php?title=$1 [L,QSA]
Another version I got somewhere or other, same outcome as above.
Ex. 3
editRewriteEngine On RewriteCond %{REQUEST_URI} !^/(stylesheets|images|skins)/ RewriteCond %{REQUEST_URI} !^/(redirect|texvc|index).php RewriteCond %{REQUEST_URI} !^/error/(40(1|3|4)|500).html RewriteCond %{REQUEST_URI} !^/favicon.ico RewriteCond %{REQUEST_URI} !^/robots.txt RewriteRule ^(.*)$ /index.php?title={ampescape:$1} [L,QSA]
Interesting result from this one - no matter what page I tried to access, I would get a "bad title" result. I wonder exactly what title that rewrite rule was attempting to pass to mediawiki?
Ex. 4
editRewriteEngine On RewriteCond %{REQUEST_URI} !^/(stylesheets|skins|images|config)/ RewriteCond %{REQUEST_URI} !^/(index|redirect|texvc).php RewriteCond %{REQUEST_URI} !^/error/(40(1|3|4)|500).html RewriteCond %{REQUEST_URI} !^/(favicon.ico|robots.txt) RewriteRule ^(.*)$ /index.php?title=${ampescape:$1} [L,QSA]
Interesting result, again - I think this one would work, except for some reason, it redirects any page I try to go to, to "Main_Page" then sits there for a moment, finally giving me a "Couldn't open the page, too many server redirects" page - if I could figure out why it redirects everything, including Main_Page itself, to Main_Page, then I bet I could beat this annoying bug
Ex. 5
edit<Files .*> Order Deny,Allow Allow From All </Files> RewriteEngine On # Don't rewrite requests for files in MediaWiki subdirectories, # MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt # add "|config" for the setup-routine in the line below, after skins RewriteCond %{REQUEST_URI} !^/(stylesheets|images|skins)/ RewriteCond %{REQUEST_URI} !^/(redirect|texvc|index).php RewriteCond %{REQUEST_URI} !^/error/(40(1|3|4)|500).html RewriteCond %{REQUEST_URI} !^/favicon.ico RewriteCond %{REQUEST_URI} !^/robots.txt RewriteRule ^/(.*)$ /index.php/$1 [L,QSA] # close the php security hole... php_flag register_globals off
This one ends up doing nothing - I get a "file not found 404" error for http://domain.tld/Main_Page or http://domain.tld/index.php/Main_Page - and still get the ampersand problem with http://domain.tld/index.php?title=Main_Page
Anyway, these are driving me batty batty batty <bigger>batty</bigger>! Blargh! Does anybody know what I can do to fix this? I never had this problem before I switched to dreamhost, which runs PHP as a CGI module. I really need help! -- ℑilver§ℑide 08:43, 8 January 2006 (UTC)
How make a very short URL? HELP!!
edit1. In files (after unzip file with MediaWiki) there are not any httpd.conf file.
2. File .htaccess there are in includes/ languages/ maintenance/ math/ tests/ directory.
That is only in directory in my computer, after upload to server this files disappear.
Server is provided by ISP.
... and after read Using a very short URL i have no idea how make a very short URL. HELP!!
85.219.173.251 11:21, 26 February 2006 (UTC)
Articles with ampersands in their names
editHello, I'm using very short URLs on my website via .htaccess (unfortunately, I don't have access to httpd.conf), and as a result I can't access articles with & in them. (The wiki tries to load a page with the name of the article before the ampersand.) I realize this is a common problem people have been having, and I had an htaccess file previously that was able to replace the ampersands in that context, but I lost that file and am unable to replicate those results. Note that using %26 in the article name seems to have the same effect as an ampersand (in that everything before the %26 is loaded.)
Here's the code I'm using in my .htaccess file:
RewriteCond %{REQUEST_URI} !^/(stylesheets|images|skins)/ RewriteCond %{REQUEST_URI} !^/(redirect|texvc|index).php RewriteCond %{REQUEST_URI} !^/(40(1|3|4)|500).shtml RewriteCond %{REQUEST_URI} !^/favicon.ico RewriteCond %{REQUEST_URI} !^/robots.txt RewriteRule ^/?(.*)$ /index.php?title=$1 [L,QSA]
I feel like there should be a line that could be added to make ampersands not be a problem, but I don't know how to do that, exactly. I realize that a lot of other people are having this problem, so a solution would be much appreciated. --LostLeviathan 19:20, 16 March 2006 (UTC)
- I've come up with a partial solution: Preface the above with
RewriteCond %{REQUEST_URI} !^/.*&.*
and then add a separate
RewriteCond %{REQUEST_URI} ^/.*&.* RewriteRule ^/?(.*)&(.*)$ /index.php?title=$1\%26$2 [L]
to handle titles with an ampersand in them. This works great for article titles with just one ampersand. And you could add another special case for articles with two ampersands, another for those with three, etc... but does anyone have clever enough code to allow for unlimited ampersands? --LostLeviathan 22:27, 16 March 2006 (UTC)
- In my configuration it seems to work pretty well. 194.208.210.167 22:05, 5 April 2006 (UTC) It's a Mediawiki version 1.4.10 and the following code in /etc/apache/conf.d/sitename :
RewriteEngine On # Don't rewrite requests for files in MediaWiki subdirectories, # MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt RewriteCond %{REQUEST_URI} !^/(stylesheets|images|skins|download)/ RewriteCond %{REQUEST_URI} !^/(redirect|texvc|index).php RewriteCond %{REQUEST_URI} !^/error/(40(1|3|4)|500).html RewriteCond %{REQUEST_URI} !^/favicon.ico RewriteCond %{REQUEST_URI} !^/robots.txt RewriteRule ^/(.*)$ /index.php/$1 [L,QSA]
-- can anyone tell us, why this (short urls) isn't just the simple plain standard on wikimedia sites ? 194.208.210.167 22:05, 5 April 2006 (UTC)
- I have to use the 'noescape|NE' (no URI escaping of output) flag when the result of a rewrite contains an %:
RewriteCond %{REQUEST_URI} ^/.*&.* RewriteRule ^/?(.*)&(.*)$ /index.php?title=$1\%26$2 [L,NE]
--Freddy Vulto, 20:55, 21 July 2006 (CEST)
very short URL on easyPHP/Windows Install
editHi,
I got this easyPHP setup on a windows XP box. the mediawiki is sitting in the www folder and so the URL is this ugly http://mydomain.com/mediawiki-1.5.5/index.php/Main_Page instead of http://mydomain.com I tried to shorten the url with the advice above but had no luck so far. .htaccess options are not working on Windows, and the httpd.conf changes only produced errors, or strange or no results. Simply changing the document root did not work either.
Anybody out there with an easyPHP install who can help?
A simple "Alias" works fine for me
editI must be missing something, because simply adding a straight-forward:
Alias /wiki /home/wiki/index.php
to httpd.conf seems to work fine in my setup. No mod_rewrite, patches or other tricks needed. Tested it with editing ampersand titles and it all works fine. (I'll be sure to update this if I later find differently.) This is with MediaWiki 1.6.3 and Apache 1.3.32. --Greg Ubben, 2006-06-28
- what are you talking about? it doesn't even pretend to be working for me Lo'oris 13:34, 7 August 2006 (UTC)
- In my site this works well, but I can't access API without doubling some slashes (AutoWikiBrowser doesn't recognise this "//"s). --Cybermandrake 12:26, 26 April 2011 (UTC)
Anyone successfully use very short URL's with Dreamhost lately?
editI used Dreamhost admin to install today (Jul, 14 2006) and have tried most everything I can think of to get very short URL's to work. In all cases, nothing happens--nothing breaks either. I have installed it at the document root (hence no "wiki" folder). Dreamhost forums and wiki docs are useless in my case. I will either pay someone $1,000, or give them a boot to the head, to answer this question (my choice).
- Me too (except not the $1k). So far, I just accept ugly URLs rather than waste too much effort on it. pfctdayelise 06:05, 11 August 2006 (UTC)
I did it! I did it!!.. Actually it was more of a anti-climax.. becasue after reading all the posts on various forums and wiki's I was preparing for a long night ahead of me to get this working. However it started working after two trials. Here's what is did.
Installed mediawiki using the oneClick Install on wiki.myhost.org and then changed
this ->
$wgArticlePath = "$wgScript?title=$1";
->to this
$wgArticlePath = "/$1";
and then created a file .htaccess at ~/wiki.myhost.org/.htaccess and added the following lines in it
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?title=$1 [L,QSA]
Im not sure at this point how completely it works, as i have started experimenting it. It sure rendered the Main_page and all the pages linked to the Main_page correctly, including Search. So im happy for now. Will report back if I run into issues. If I dont assume I'm doing just fine. Thanks for the help guys.
And btw I guess someone owes me $1k ;) feel free to pay me in full at wmf:Fundraising
Cheers
Is ANY of this recommended?
editThese pages are very confusing. Are ANY of the methods approved of?Jonathan1 22:02, 16 August 2006 (UTC)
- Tried all these methods too, and I cant have a fully working one, all url with a colon such as user:... or special:... are access forbidden by the .htaccess (A2 - 29 August 2006) plz help ! 29 August 2006 —The preceding unsigned comment was added by 86.213.204.247 (talk • contribs) .
- See my comment about Colon issue with Very Short URLs on Windows --Kenneth 23:51, 16 October 2006 (UTC)
Uh... please someone talk about this .htaccess more...
editok... so... we got /wikiFolderName/index.php?title=Namespace:Pagename and we wanna have every request look like: /wikiFolderName/Namespace:Pagename and remove "index.php?title=" from every URL... and need to do this from HTACCESS for ONLY one folder... and everything i seem to try gives me a 404... and i feel like i am missing something. 05:32, 30 August 2006 —The preceding unsigned comment was added by Dsgncr8or (talk • contribs) .
- Please sign your posts using: ~~~~ thanks. Odessaukrain 06:24, 4 September 2006 (UTC)
- Same for me...
See: Talk:Eliminating_index.php_from_the_url#The_biggest_problem_with_this_article:_it_doesn.27t_work for the reason for this and the Template:CleanupConfusing tag Odessaukrain 07:06, 4 September 2006 (UTC)
Colon issue with Very Short URLs on Windows
editIf you try the "Simple httpd.conf or .htaccess method", to get the http://www.foo.com/Main_Page effect, running Apache on a Windows machine, you may receive the following error when visiting pages with a colon (ie Special:Random):
403 Forbidden You don't have permission to access /Special:Random on this server. Apache/2.0.55 (Win32) PHP/5.0.5 Server at test.mydomain.com Port 80
This is apparently caused by Apache seeing the colon as indicating a drive mapping. Using the same setup on a Linux-Apache setup worked perfectly. Go Linux!
If you are intent on running it on windows, just make sure that your wiki is under a folder such as http://www.foo.com/wiki/Main_Page and you can have at least this short of a URL.
--Kenneth 23:51, 16 October 2006 (UTC)
Is there any way to solve this problem?
How to change www.mysite.com/wiki/index.php?title=..... to wiki.mysite.com/Article_name ?
editAnyone can show step by step or show explanaition somewere.
For me worked this
editGentoo, Apache 2.0, MediaWiki 1.9.3
- 0. I installed (unzipped) mediawiki in /path/to/mediawiki/ folder to wiki subfolder
- test your installation, by visiting url of wiki for example www.yourdomain.com/wiki
- you have to get www.yourdomain.com/wiki/index.php?title=Main_Page
- 1. first change your DocumentRoot in <VirtualHost> from /path/to/mediawiki/ to /path/to/mediawiki/wiki
- now you can test the change (restart or graceful for apache required) typing in browser www.yourdomain.com/
- you will get www.yourdomain.com/wiki/index.php?title=Main_Page and it will NOT work
- 2. you have to change in LocalSettings.php value of $wgScriptPath
- from:
$wgScriptPath = "/wiki";
- to:
$wgScriptPath = "";
- when you try www.yourdomain.com now you will get www.yourdomain.com/index.php?title=Main_Page
- 3. now you have to enable rewriting mode for apache and modify your <VirtualHost> to
<VirtualHost *:80> ServerAdmin your@mail.com DocumentRoot /path/to/mediawiki/wiki ServerName www.yourdomain.com ServerAlias yourdomain.net ErrorLog /path/to/logs/error_log CustomLog /path/to/logs/access_log combined RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/([^/]*)$ /index.php?title=$1 [PT,L,QSA] </VirtualHost>
- when you try www.yourdomain.com/ you will get www.yourdomain.com/Index.html (or Index.htm or Index.php, whatever you have set as DirectoryIndex in http.conf or in <VirtualHost>), this happends because internally www.yourdomain.com is transformed to www.yourdomain.com/index.html (bacuase of DirectoryIndex setting), than it's modified with mod_rewrite to www.yourdomain.com/index.php?title=index.html and you will see Index.php wiki page
- 4. to be not directed to index.html wiki page modify rewrite conditions
<VirtualHost *:80> ServerAdmin your@mail.com DocumentRoot /path/to/mediawiki/wiki ServerName www.yourdomain.com ServerAlias yourdomain.net ErrorLog /path/to/logs/error_log CustomLog /path/to/logs/access_log combined RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !/index.html RewriteCond %{REQUEST_URI} !/index.htm RewriteCond %{REQUEST_URI} !/index.php RewriteRule ^/([^/]*)$ /index.php?title=$1 [PT,L,QSA] </VirtualHost>
- now you will be redirected correctly to www.yourdomain.com/index.html?title=Main_Page
- 5. last thing you have to add
$wqArticlePath = "/$1";
- to LocalSettings.php
- finally you are redirected from www.yourdomain.com/ to www.yourdomain.com/Main_Page
MediaWiki 1.82 .htaccess method for wikis stored in subfolder of root
editI have gotten Mediawiki Pretty URLs to work here at [2] by using this configuration. I have my wiki in the wiki5 folder. I'm running, MediaWiki 1.82
Add to .htaccess
AddHandler application/x-httpd-php5 .php
The above line directs all php files to processed using PHP5
#Redirect http://muscatelli.info to http://www.muscatelli.info RewriteCond %{HTTP_HOST} ^muscatelli.info/wiki5 RewriteRule ^(.*)$ http://www.muscatelli.info/wiki5/$1 [r=301,L]
Note: the above is used to redirect all addresses with the www removed to [www.muscatelli.info] to help Google Ranking and is not necessary for the code to work! Also note that my wiki is in the directory: wiki5
# anything that contains a dot without a colon should be left alone RewriteRule ^[^:]*\. - [L] # anything that contains a slash without a colon should be left alone RewriteRule ^[^:]*\/ - [L] # redirect to main page RewriteRule ^/*$ /wiki5/index.php?title=Main_Page [L,QSA] # anything else is to be treated as a title RewriteRule ^(.+)$ /wiki5/index.php?title=$1 [L,QSA] # anything that contains a slash is to be left alone.
Change in LocalSettings:
$wgArticlePath = "$wgScriptPath/$1";
Speed issues on Site
editAfter implementing the required steps and creating very short URLs, I realized that the speed on my site decreased by a lot. Is there any way to fix this issue?
New Ampersand Problem
editHi all,
I've got a problem with ampersands that I haven't seen so far. Here's the .htaccess code I'm using (a combination of the two fixes suggested on this article, with minor changes):
RewriteEngine on RewriteRule (images|skins)/ - [L] RewriteRule \.php$ - [L] RewriteRule ^$ /wiki/Main_Page [R,L] RewriteRule ^[^:]*\.(php|src|jpg|jpeg|png|gif|bmp|css|js|inc|phtml|pl|ico|html|shtml)$ - [L,NC] RewriteRule ^index.php?title - [L] RewriteRule ^(.*)\&(.*)$ $1\%26$2 RewriteRule ^wiki/?(.*)$ /mediawiki/index.php?title=$1 [L,QSA]
For some reason, it's displaying the name of the article — with ampersands properly displayed — followed by a slash and then a repeat of everything in the article name before the ampersand. For example, the article L&N Railroad becomes L&N Railroad/L. Any ideas or suggestions? --24.254.117.203 20:57, 24 March 2007 (UTC)
- People having this problem should try the "THE_REQUEST" line given at Manual:Short URL/Allowing for escaped characters in URI. It solved my problems with plus signs and ampersands. And unlike some other ampersand hacks it doesn't break "what links here" pages. I'm running MediaWiki version 1.11.0. --Kevin332 13:00, 30 December 2007 (UTC)
Change from /wiki/index.php to /w in XAMPP?
editI have a webserver (Apache 2.2.3, PHP 5.2.0, mySQL 5) and I can't seem to get pages with namespaces to work using a .htaccess + LocalSettings.php hack. Contents of .htaccess:
RewriteEngine On # anything that contains a dot without a colon should be left alone RewriteRule ^[^:]*\. - [L] # anything that contains a slash without a colon should be left alone RewriteRule ^[^:]*\/ - [L] # redirect to main page RewriteRule ^/*$ /wiki/index.php?title=Main_Page [L,QSA] # anything else is to be treated as a title RewriteRule ^(.+)$ /wiki/index.php?title=$1 [L,QSA]
Contents of LocalSettings.php:
<?php # This file was automatically generated by the MediaWiki installer. # If you make manual changes, please keep track in case you need to # recreate them later. # # See includes/DefaultSettings.php for all configurable settings # and their default values, but don't forget to make changes in _this_ # file, not there. # If you customize your file layout, set $IP to the directory that contains # the other MediaWiki files. It will be used as a base to locate files. if( defined( 'MW_INSTALL_PATH' ) ) { $IP = MW_INSTALL_PATH; } else { $IP = dirname( __FILE__ ); } $path = array( $IP, "$IP/includes", "$IP/languages" ); set_include_path( implode( PATH_SEPARATOR, $path ) . PATH_SEPARATOR . get_include_path() ); require_once( "includes/DefaultSettings.php" ); # If PHP's memory limit is very low, some operations may fail. # ini_set( 'memory_limit', '20M' ); if ( $wgCommandLineMode ) { if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) { die( "This script must be run from the command line\n" ); } } elseif ( empty( $wgNoOutputBuffer ) ) { ## Compress output if the browser supports it if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' ); } $wgSitename = "Onekopakaspace Wiki"; ## The URL base path to the directory containing the wiki; ## defaults for all runtime URL paths are based off of this. $wgScriptPath = "/wiki"; ## For more information on customizing the URLs please see: ## http://www.mediawiki.org/wiki/Manual:Short_URL $wgEnableEmail = false; $wgEnableUserEmail = false; $wgEmergencyContact = "admin@localhost"; $wgPasswordSender = "admin@localhost"; ## For a detailed description of the following switches see ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent ## There are many more options for fine tuning available see ## /includes/DefaultSettings.php ## UPO means: this is also a user preference option $wgEnotifUserTalk = false; # UPO $wgEnotifWatchlist = false; # UPO $wgEmailAuthentication = false; $wgDBtype = "mysql"; $wgDBserver = "localhost"; $wgDBname = "wikidb"; $wgDBuser = "wikiuser"; $wgDBpassword = "*********"; $wgDBport = "5432"; $wgDBprefix = "wiki_"; # Schemas for Postgres $wgDBmwschema = "mediawiki"; $wgDBts2schema = "public"; # Experimental charset support for MySQL 4.1/5.0. $wgDBmysql5 = false; ## Shared memory settings $wgMainCacheType = CACHE_NONE; $wgMemCachedServers = array(); ## To enable image uploads, make sure the 'images' directory ## is writable, then set this to true: $wgEnableUploads = true; $wgUseImageResize = true; $wgStrictFileExtensions = false; # $wgUseImageMagick = false; # $wgImageMagickConvertCommand = '../../../../../../TeX/imagick/; ## If you want to use image uploads under safe mode, ## create the directories images/archive, images/thumb and ## images/temp, and make them all writable. Then uncomment ## this, if it's not already uncommented: $wgHashedUploadDirectory = false; ## If you have the appropriate support software installed ## you can enable inline LaTeX equations: $wgUseTeX = false; $wgLaTexCommand = '../../../../../../wikitex/miktex/bin/latex.exe'; $wgDvipsCommand = '../../../../../../wikitex/miktex/bin/dvipng.exe'; $wgLocalInterwiki = $wgSitename; $wgLanguageCode = "en"; $wgProxyKey = "1c8642112e67359d43d86d2d14604673bf5ae6c228d8eab2a8b10255c14311"; ## Default skin: you can change the default skin. Use the internal symbolic ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook': $wgDefaultSkin = 'cavendish'; ## For attaching licensing metadata to pages, and displaying an ## appropriate copyright notice / icon. GNU Free Documentation ## License and Creative Commons licenses are supported so far. # $wgEnableCreativeCommonsRdf = true; $wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright $wgRightsUrl = ""; $wgRightsText = ""; $wgRightsIcon = ""; # $wgRightsCode = ""; # Not yet used $wgDiff3 = ""; # When you make changes to this configuration file, this will make # sure that cached pages are cleared. $configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) ); $wgCacheEpoch = max( $wgCacheEpoch, $configdate ); require_once("$IP/extensions/CharInsert/CharInsert.php"); require_once( "$IP/extensions/SpamBlacklist/SpamBlacklist.php" ); $wgUseAjax = true; require_once( 'extensions/CategoryTree/CategoryTree.php' ); include('extensions/googleVideo.php'); include('extensions/youtube.php'); include('extensions/quicktime.php'); require_once( "{$IP}/extensions/Cite/Cite.php" ); require_once( "$IP/extensions/ImageMap/ImageMap.php" ); #CheckUser for Special:CheckUser require_once("$IP/extensions/CheckUser/CheckUser.php"); $wgGroupPermissions['sysop']['checkuser'] = true; $wgCheckUserLog = true; include( "$IP/extensions/WikiChat.php" ); include("extensions/calendar/Calendar.php"); require_once( "$IP/extensions/ConfirmEdit/ConfirmEdit.php" ); require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" ); require_once('extensions/googleCalendar.php'); include('extensions/audioembed.php'); #This is the experimental line, Namespaced articles don't function... #$wgArticlePath = "/wiki/$1"; $wgLogo = "$wgScriptPath/skins/common/images/wikilogofinal.png"; $wgAllowUserCss="true"; $wgAllowUserJs="true"; require_once("$IP/extensions/Newuserlog.php"); require_once("$IP/extensions/inputbox.php"); include_once("$IP/extensions/Renameuser/SpecialRenameuser.php"); #used for renaming users #require_once( 'extensions/BreadCrumbs/BreadCrumbs.php' ); require_once ("$IP/extensions/StringFunctions/StringFunctions.php"); require_once("$IP/extensions/ExtensionClass/ExtensionClass.php"); require_once("$IP/extensions/SysopSidebar/SysopSidebar.php"); $wgGoogleMapsKeys = array( "onekopakaspace.strangled.net" => "ABQIAAAADDCRRhwDCl3l-c3ySaR9nRTXYZXlb1et7TGM0Dr-ChXB4LkGfRTYHW6WA3aObfRpdBiIXysFOCaYmA", "24.19.197.89" => "ABQIAAAADDCRRhwDCl3l-c3ySaR9nRShqMzuUjt0nRZAQMvrbRV3QbNFChTTe7O1oEo73pA5Upq5gNMRkmdFHw", "192.168.1.102" => "ABQIAAAADDCRRhwDCl3l-c3ySaR9nRQ3xZ8itk8Qm3mo0bDOTeoyembSNRTKjGjNkMWNnpEWS4IY8vmUcAzgMA"); require_once( "extensions/GoogleMaps/GoogleMaps.php" ); $wgGoogleMapsEnablePaths = true; ?>
Now remember, I want /wiki/index.php?title=$1 = /w/$1
Look at this page for the error caused by Articles that have namespaces: http://onekopakaspace.strangled.net/w/Special:Log
--Onekopaka 04:55, 8 May 2007 (UTC) For a faster response put your answer on my User talk page on my wiki
This used to appear on the old page
editThis is what remained of m:Using a very short URL which was not given its own page. Odessaukrain 23:26, 9 October 2007 (UTC)
Lighttpdediturl.rewrite-once = ( "(^/(skins|images|css\?).*$)" => "$1", "^/([^?]*)(?:\?(.*))?" => "/index.php?title=$1&$2", )
Warnings and disclaimereditThis configuration is totally unsupported by the Mediawiki development team. Therefore, future versions may have modifications that break this setup. Indeed, Mediawiki's current code must be modified in two places before it can work. Also, it displaces the location for wiki pages. Allowing users to load non-wiki pages in the same webpage will be difficult to set up. What configuration??? The above or below! Fix this header please.
ModificationseditPatching ApacheeditA few Apache 2 packages are built with this patch already applied (e.g., Gentoo's). Otherwise: Get the Apache 2 source. Download the patch. Apply, compile, install. httpd.confeditIn RewriteEngine On # Don't rewrite requests for files in MediaWiki subdirectories, # MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt RewriteCond %{REQUEST_URI} !^/(stylesheets|skins|images|config)/ RewriteCond %{REQUEST_URI} !^/(index|redirect|texvc)\.php$ RewriteCond %{REQUEST_URI} !^/error/(40(1|3|4)|500)\.html$ RewriteCond %{REQUEST_URI} !^/(favicon\.ico|robots\.txt)$ RewriteMap ampescape int:ampescape RewriteRule ^/(.*)$ /index.php?title=${ampescape:$1} [L,QSA] Note that the line that prevents rewriting requests for error documents may vary from site to site.
Note that you can't use that in
Making it work with robots.txteditIt is also possible to make regular pages appear shortened like this but other pages will appear in full. This could be done a number of ways, but the most common are to make edit links like http://wiki.site.tld/edit.php?title=Article_Name or http://wiki.site.tld/edit/Article_Name. The first one should be obvious how to implement and the second is just as easy as using a single rewrite rule. This would also have to be done for any other features which you wish to hide from robots, for instance history. Method for DebianeditDON'T install the mediawiki package. It installs to /var/lib/mediawiki1.7 (On stable at least), and makes an alias. This interferes with all the redirects. instead, install from source to /var/www/mediawiki. Then run chmod a+wx /var/www/mediawiki/config then install as you would the package (http://localhost/mediawiki/config, follow instructions.) Then run a2enmod rewrite. Edit your virtualhosts file and add the folowing: RewriteEngine on # Don't rewrite requests for files that really exist or should return 404. RewriteCond %{REQUEST_URI} !^/favicon.ico RewriteCond %{REQUEST_URI} !^/robots.txt RewriteCond %{REQUEST_URI} !^/mediawiki/ # Rewrite http://wiki/article -- this is the main rule RewriteRule ^/(.*)$ /mediawiki/index.php/$1 [L,QSA] Then add this to /var/www/mediawiki/LocalSettings.php $wgArticlePath = "/$1"; Run apache2ctl graceful one more time, and you should be done. |