Manual talk:Short URL/Page title -- PHP as a CGI module, no root access
[edit] Doesnt work
This is in regards to the old version, below:
this doesnt work, but at least it is the first Short URL solution which did not crash my site completely . I "only" get my 404 screen instead. Any suggestions? My webpages look like this:
www.name.com/wiki/index.php?title=name_of_page
My localaccess.php:
$wgScriptPath = "/wiki"; $wgScript = "$wgScriptPath/index.php"; $wgRedirectScript = "$wgScriptPath/redirect.php"; ## If using PHP as a CGI module, use the ugly URLs #$wgArticlePath = "$wgScriptPath/$1";
User:Odessaukrain 07:35, 6 October 2007 (UTC)
[edit] Older version
this is the older original version which appeared on this page. It doesnt have as many details as the newer version, it didnt personally work for me. Odessaukrain 22:54, 10 October 2007 (UTC)
|
After a lot of trial and error, this works for me. Don't ask me how it works! I hope this helps someone but I can't guarantee it will work for anyone else. Good points
Problems
[edit] In LocalSettings.phpFirst, remove or add a "#" at the beginning of these two lines: #$wgArticlePath = "$wgScript/$1"; #$wgArticlePath = "$wgScript?title=$1"; and add this third line: $wgArticlePath = "/$1"; [edit] In .htaccessThis file goes in the .htaccess, found in the public_html root directory. RewriteEngine on RewriteRule ^index\.php$ index.php [L,QSA] #added this line to make the site look right (otherwise it was Times New Roman and no style...) RewriteRule ^skins/(.*)$ skins/$1 [L] #can't remember if this line is needed but it can't do any harm... RewriteRule ^extensions/(.*)$ extensions/$1 [L] #This works perfectly... except for when there's an ampersand & in the article title RewriteRule ^index.php/?(.*)$ /index.php?title=$1 [L,QSA] #Adding this to get rid of the "index.php/" as well, which looks much nicer #Not replacing the line above as I want the links Google has (index.php/...) still to work. RewriteRule ^/?(.*)$ /index.php?title=$1 [L,QSA] |
Odessaukrain 22:41, 10 October 2007 (UTC)
[edit] Two problems with this fix
- My logo no longer appears.
- Any site/link found a template does not work. The site looks for /wiki/ folder. Odessaukrain 00:10, 13 October 2007 (UTC)
[edit] No external links on Main_Page work
Logo, or other images on front page do NOT work. The creative commons logo does work. Why? Because it changes the url to
www.site.com/Folder/image.png.php
Meaning it tries to find a WIKI page with the name of the file's relative url. So, another example could be
Original:
www.site.com/img/file.jpg
Rewritten:
www.site.com/Img/file.jpg.php "The wiki doesn't have a page called Img/file.jpg.php"
Any ideas of why the rewrite code does this?
..nevermind, it fixed itself in a matter of hours. Weird, thouhg.
[edit] $wgArticlePath = "/$1";
I really suggest changing
$wgArticlePath = "/$1";
to
$wgArticlePath = "$wgScriptPath/$1";
It makes it work when the wiki is installed in (for example) /wiki
Cristan 11:51, 21 November 2007 (UTC)
[edit] Main_Page
RewriteRule ^/*$ /wiki/index.php?title=Main_Page
causes problems when you rename the main page. You would rather want to do:
RewriteRule ^/*$ /wiki/index.php
[edit] Alternate Version II
Yikes! After fighting with this for hours, I FINALLY figured out how to make it work on GoDaddy.
I have a hosting account with GoDaddy, and I've been trying to set it up so that I can go straight to http://server/Article_page, but I could tell something was wrong, because the config scripts would come up with no stylesheet applied. When I manually navigated to the URL of the stylesheet, I got a 500 error. The culprit ended up being line 6 in the Alternate Version II instructions:
RewriteRule ^(.+) /path/to/web/directory/$1 [L]
Since GoDaddy seems to have their webservers set up to chroot into the web's root directory, I felt this should be appropriately rewritten as:
RewriteRule ^(.+) /$1 [L]
However, the CORRECT way to write this line ended up being:
RewriteRule ^(.+) $1 [L]
And afterwards, all was well! Hope this helps someone!
I'm using phpbb2 in my main directory with some url rewrites in htaccess, before doing what you said it pulled up my main website with no CSS file, now it just pulls up my homepage... instead of the wiki.
Thanks a LOT for these rules! Worked great for my suprt short url setup.
[edit] Problems with File Upload
After doing this with MediaWiki 1.11.1 i lost the abitity to upload images (after pressing the upload it brings me to page Special:Uploads which is blank), but I still can edit pages. The original adress line of Main Page was sub.mydomain.com/w/index.php?title=Main_Page , it turned into sub.mydomain.com/Main_Page, slashes and dots in names do not work (though it's not a big deal). Does anyone can advice with restoring upload possibility? (i dont have access to httpf, only to .htaccess) Any additional info can be supplied (just not quite sure, which) --Redsunrising 00:46, 12 February 2008 (UTC)
[edit] Articles with dots/periods (.)
If your article title has dots in it, using the first example will fail because of the following rule.
# anything line which contains a dot (.) without a colon (:) should be left alone RewriteRule ^[^:]*\. - [L]
e.g. http://wiki/Mysite.com.au will produce a 404 Not Found. If you have a solution, post it!
[edit] Alternate version II and permanent redir
Hi everyone, the alternate version II works perfectly on my website.
I would like to do a permanent redirection, to avoid Google referencing http://server.com and http://www.server.com, so I added the code below, which unfortunately do not resolve the problem. Any idea ? Rmatt 22:48, 16 April 2008 (UTC)
RewriteCond %{HTTP_HOST} !^www.socialopedia.org$
RewriteRule ^(.*)$ http://www.socialopedia.org/$1 [R=301]
It is actually VERY bizarre, because the redirection works from my office (Linux + Firefox), from my Windows + IE, but not from Windows + Firefox, where I land on a http://www.socialopedia.org/Http://www.socialopedia.org/ page ?! I will do a permanent redir from this page, if nobody has an alternative !
[edit] RSS/Atom Feed
Everything works well. But...I want to use the Atom Feed as a sitemap for Google. But in the "recent changes" the version links link to "...index.php?_title". Now Google reads out the long URL instead of the short one. Has anyone a solution? I tried to understand the feed.php, but I don't find the request for it and where it get its URL Information. --HSchier81 12:11, 29 May 2008 (UTC)
[edit] Error with page title abcde.com
I've applied and it worked fine, but there is always error by page title abcde.com, surely no domain .com after the main domain.
Does anyone know how to solve it? would like to use this short url variant, but the title .com as well.
[edit] Ampersand (&) and Question Mark (?)
Is there any possibility to make ampersands (&) and question marks (?) work in the URL? I mean it is a common used symbols - especially in titles. Also the plus symbol (+) doesn't work correctly. It is always declared as a space like the underline (_). Thanks in advance.
[edit] Not working when $wgUsePathInfo = false;
Hi, when I set $wgUsePathInfo = false, I get the following error at aseanpedia.com:
|
Yet, when I set $wgUsePathInfo = true in contradiction to the advice given, it works! I hope there are no side-effects, though, as I am no expert in tweaking. — PM Poon 20:16, 7 March 2009 (UTC)
[edit] "Solution works for" section for common hosts and server configurations
I think users would be helped if this page had notations in each solution such as:
| This solution works for | Yes | No |
|---|---|---|
| 1&1 shared hosting | Yes | |
| GoDaddy shared hosting | Yes | |
| WAMPServer Apache 2.2.13, MySQL 5.1.36, PHP 5.2.11 | No | |
| etc | Yes |
Agree? --Jonathan Kovaciny 15:56, 24 May 2010 (UTC)
[edit] More generic solution, does not hardcode search for . (dot) or / (slash)
Having run a variety of MW installs for many years, when I recently took over maintenance of a few much older installs I figured I would get current state-of-the-art rewrite rules for the new ones I was maintaining. The new rules bit me, though, causing many pages of existing wiki content to break since they had slash characters creating the visual appearance of hierarchy. I'm contributing this back up showing what's worked for me across a large number of installs:
RewriteEngine On # If a file exists, serve the file, do not redirect to the wiki RewriteCond %{REQUEST_FILENAME} !-f # If a directory exists, serve the file, do not redirect to the wiki RewriteCond %{REQUEST_FILENAME} !-d # Other RewriteCond rules can be added for apache handler-controlled # special pages or server alias/script-alias not under the wiki directory: # RewriteCond %{REQUEST_URI} !server-status RewriteRule ^(.+)$ index.php?title=$1 [L,QSA]
--Pckizer 14:29, 25 October 2010 (UTC)
Other Alternatives didn't work for me, but this one does :)