Help with Wikipedia Short URLs

New to mod_rewrite? This is a good place to start.

Help with Wikipedia Short URLs

Postby Deceth » Tue Jun 24, 2008 9:47 am

Hi,

I've been having a hard time getting my Wikipedia setup to work with short url's.


My install is at:

http://www.looble.com/wiki/

The main page is accessible at:

http://www.looble.com/wiki/index.php5?title=Main_Page

I'd like to main page to actually show up as:

http://www.looble.com/wiki/Main_Page and other pages to show up similarly, using their page title.


Here is my current .htaccess file:

[code]RewriteEngine On
RewriteBase /
RewriteRule ^[^:]*\. - [L]
RewriteRule ^[^:]*\/ - [L]
RewriteRule ^/*$ index.php5?title=Main_Page [L,QSA]
RewriteRule ^(.+)$ index.php5?title=$1 [L,QSA]

With this, I am always taken to a white page. I've tried many variations without luck, any help would be appreciated.
Deceth
 
Posts: 5
Joined: Tue Jun 24, 2008 9:37 am

Postby richardk » Tue Jun 24, 2008 2:48 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^$ ./index.php5?title=Main_Page [QSA,L]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.+)$ ./index.php5?title=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Deceth » Wed Jun 25, 2008 4:34 am

Thanks for the reply! I tried your code but unfortunately the pages still come up blank/white.

Is there a way to see where the mod_rewrite is actually trying to send me? This could help me debug the problem. Obviously its not generating the link exactly correct or it would work and if I could see what it was generating I could play around with it until finally getting the right output.

Just as another note, I've tried basically all of the solutions listed in the MediaWiki installation section where they provide instructions for creating a .htaccess file for generating short URLs. For some reason, they don't work for me.

mod_rewrite is enabled on my server. I do use a short url permalink structure for a Wordpress blog on the same server. I've also tried some dumb generic code to verify it is even reading my .htaccess file by putting in something like:

RewriteRule Google http://www.google.com

... and this did work and forwarded me to the Google site. So, something with my code is off, just no idea what.
Deceth
 
Posts: 5
Joined: Tue Jun 24, 2008 9:37 am

Postby richardk » Thu Jun 26, 2008 1:29 pm

Do you still want to fix this or are you going to use a sub domain now (this thread)?

If you want this to work, does this work on it's own?
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^$ ./index.php5?title=Main_Page [QSA,L]


If it does, try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^$ ./index.php5?title=Main_Page [QSA,L]
RewriteRule ^([^/:.]+)/?$ ./index.php5?title=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Deceth » Thu Jun 26, 2008 2:15 pm

Sorry for starting the second thread, don't want to cause confusion! The other thread is mostly about the confusion that it works under one subdomain but not the other...!

I've been trying to get it working myself for a long time and so was very happy when I saw it finally work on the first subdomain and would be more than happy to use it with a subdomain if it did work on the proper one. That being said, I'd still like to get this working so thanks again for the reply!

In response to your question, the following does NOT work... :(

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^$ ./index.php5?title=Main_Page [QSA,L]


I've been trying to figure this out for a while and I've realized that perhaps there is a conflict due to my .htaccess file in a higher level directory. My root directory contains an installation of Wordpress which is http://www.looble.com. Since the Wiki is in http://www.looble.com/wiki/ or currently http://www.looble.com/w/ then it likely inherits something from the Wordpress .htaccess.

The following is the .htaccess file in the root directory for Wordpress:

Code: Select all
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


Thanks again for your help.
Deceth
 
Posts: 5
Joined: Tue Jun 24, 2008 9:37 am

Postby richardk » Sat Jun 28, 2008 4:59 pm

Try this in your document root .htaccess file
Code: Select all
Options +FollowSymLinks

<IfModule mod_rewrite.c>
  RewriteEngine On

  # BEGIN WordPress
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule !^(wiki|w)(/.*)?$ /index.php [L]
  # END WordPress
</IfModule>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Deceth » Mon Jun 30, 2008 8:53 am

Nothing seems to be working so I think I'll just use the ugly URLs. That being said, I still have another issue:

http://www.looble.com/wiki/ will load a blank white page instead of the Wiki. The wiki itself is working fine and can be accessed by going to http://www.looble.com/wiki/index.php5

Is there a way to fix this? I've tried myself but I keep creating an infinite loop redirect which isnt good :(
Deceth
 
Posts: 5
Joined: Tue Jun 24, 2008 9:37 am

Postby richardk » Mon Jun 30, 2008 1:02 pm

Does any of the mod_rewrite work if you remove Wordpress's? It might work if you combine them into one (in your document root)
Code: Select all
Options +FollowSymLinks

<IfModule mod_rewrite.c>
  RewriteEngine On

  # BEGIN Wiki
  RewriteRule ^wiki/?$ /wiki/index.php5?title=Main_Page [QSA,L]

  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteRule ^wiki/(.+)$ /wiki/index.php5?title=$1 [QSA,L]
  # END Wiki

  # BEGIN WordPress
  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteRule !^wiki(/.*)?$ /index.php [L]
  # END WordPress
</IfModule>


/wiki/ will load a blank white page instead of the Wiki. The wiki itself is working fine and can be accessed by going to http://www.looble.com/wiki/index.php5

Is there a way to fix this?

Try the following in a .htaccess file in /wiki
Code: Select all
DirectoryIndex index.php5
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Re: Help with Wikipedia Short URLs

Postby Till Kraemer » Mon Jul 25, 2011 2:38 am

Aloha,

Sorry for replying to this thread, but I can't start new topics (I can't even use BBCode).

I'm running a multilingual wiki and I'm currently working on the mobile version. I have a subdomain for each language version and the .htaccess file for language.domain.com looks like this:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.*)$ w/index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ wiki/ [L,QSA]
RewriteRule ^/*$ wiki/ [L,QSA]

I've added a subdomain language.mobile.domain.com pointing to the same folder like language.domain.com. Now, I'd like to add a "&useFormat=mobile" to the every URL requested on the mobile subdomain.

I altered the .htaccess file like that:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.*)$ w/index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ wiki/ [L,QSA]
RewriteRule ^/*$ wiki/ [L,QSA]

RewriteCond %{HTTP_HOST} ^language\.mobile\.domain\.com$ [NC]
RewriteRule ^wiki/(.*)$ w/index.php?title=$1&useFormat=mobile [PT,L,QSA]
RewriteRule ^wiki/*$ wiki/ [L,QSA]
RewriteRule ^/*$ wiki/ [L,QSA]

...but it so does not work :( Neither does adding "mobile\.domain\.com/" to the last three "^".

Any pointers are more than appreciated!

Thanks + cheers,

Till

P.S.: Funny thing: If I add the "&useFormat=mobile" to the old RewriteRule it works perfectly, but then I can't use the non-mobile version.
Till Kraemer
 
Posts: 2
Joined: Sun Aug 24, 2008 10:41 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron