Jump to content

Topic on Project:Support desk/Flow

Short URLs when not in root directory

5
50.92.159.206 (talkcontribs)

Hi, I am new to working with MediaWiki and was having some trouble setting up short URLs.


I have my wiki configured in the /wiki folder, and would like the short URL to look like /wiki/Wiki_Page. So basically:


  • domain.com/wiki <-- location of MediaWiki index.php
  • domain.com/wiki/Wiki_Page <-- desired short URL format.


Right now my .htaccess in the /wiki folder looks like this:

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?(/.*)?$ %{DOCUMENT_ROOT}/wiki/index.php [L]


But all I get is a 404 on my root site. I should also mention that the root site also has short URLs turned on, which look something like domain.com/product/widget. I'm not sure if that affects what I am trying to do or not, but I could post that .htaccess as well, if it helps.


Anyway, I've tried everything I can think of in the RewriteRule, it may be a simple solution but my knowledge is limited. Is there someone that is able to help?

MarkAHershberger (talkcontribs)

Try this:

RewriteEngine On
RewriteBase /wiki
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /wiki/index.php?title=$1 [L,QSA]
50.92.159.206 (talkcontribs)

Beautiful, thanks so much!!!!!!!

Ciencia Al Poder (talkcontribs)

I must say that having /wiki/index.php AND the short url configured as /wiki/PAGENAME is a very bad choice. They must be on different paths.

For example, you won't be able to access now pages with titles like "index.php", "images", "README"...

MarkAHershberger (talkcontribs)

True, but most people don't care about those page names. Still, I'll try to push people to use /w/ from now on.