Forum Moderators: phranque

Message Too Old, No Replies

Need HELP For Short URLWith MediaWiki

What Is My Mistake In Editing httpd.conf File?

         

Zoomy

6:15 pm on Aug 25, 2007 (gmt 0)

10+ Year Member



Hello,

This is my first post and I need help in removing the index.php from my MediaWiki URL so that I will have a clean short URL.

I installed MediaWiki in the root directory of my domain and my URL appears as webmasterworld.com/index.php/Larry_Page. What I want is webmasterworld.com/Larry_Page just like Wikipedia website.

(Note: webmasterworld.com & webmasterworldcom in this post are just examples as I don't want to be accused of trying to promote my website here.)

I followed the manual as instructed at [mediawiki.org...] by using the root access solution.

I tried the root access solution on my server and it was working fine but I do not want the word "wiki" to appear in the URL. What shall I do?

The manual says:

If you put the wiki installation in a subdirectory such as /w, use $wgScriptPath = "/w" as appropriate.

If you put the files (such as index.php) in the root, you can use $wgScriptPath = "" in LocalSettings.php.

2. In LocalSettings.php, set the following:

$wgArticlePath = "/wiki/$1";

Remember, the virtual directory for the wiki article space should never, ever overlap or hide real files. In particular it should never, ever overlap your base installation directory or the root directory. It can be a virtual subdirectory, such as /wiki. (For example: do not try to rewrite "/wiki/Article" to "/wiki/index.php?title=Article).

3. Set up the following alias in your Apache httpd.conf. It can be in a <VirtualHost> section, or in "Aliases" section, or in your general site config. In this alias, the prefix /filesystem/path/to/my/site represents the path you installed to — the directory where MediaWiki's index.php lives. Replace the prefix as appropriate for your actual file system path.

#These must come last, and in this order!
Alias /wiki "/filesystem/path/to/my/site/index.php"
Alias /index.php "/filesystem/path/to/my/site/index.php"
For example:

Alias /wiki "c:/apache/www/w/index.php"
Alias /index.php "c:/apache/www/w/index.php"
After making modifications to httpd.conf, you might have to restart Apache to apply the changes

I followed the instruction and it was working but with the word "wiki" in the url but I don't want that word wiki in the url as I installed Mediawiki in the root directory of my domain.

This is what I did:

I added this code to my LocalSettings.php file::

$wgScript = "$wgScriptPath/index.php";

$wgArticlePath = "/wiki/$1";

I added this code to my httpd.conf file

<VirtualHost *>
ServerName mwusers.com
ServerAlias [url]www.webmasterworld.com[/url]
DocumentRoot /var/www/webmasterworldcom

#These must come last, and in this order!
Alias /wiki "/var/www/webmasterworldcom/index.php"
Alias /index.php "/var/www/webmasterworld.com/index.php"

</VirtualHost>

I installed my MediaWiki in the root directory called webmasterworldcom

But when I tried to delete the word "wiki" from the above codes, my website is not working. This is what I did:

I added this code to my LocalSettings.php


$wgScript = "$wgScriptPath/index.php";

$wgArticlePath = "/$1";

I added this code in my httpd.conf in between the VirtualHost tag:

<VirtualHost *>
ServerName mwusers.com
ServerAlias [url]www.mwusers.com[/url]
DocumentRoot /var/www/mwuserscom

#These must come last, and in this order!
Alias / "/var/www/mwuserscom/index.php"
Alias /index.php "/var/www/mwuserscom/index.php"

</VirtualHost>

What mistakes did I make? Is my "Alias / "/var/www/mwuserscom/index.php"" line to make the word "wiki" disappears correct?

What shall I do to make my URL appear as

webmasterworld.com/Larry_Page instead of mwusers.com/wiki/Larry_Page?

Many thanks in advance for your help.

jdMorgan

8:32 pm on Aug 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You cannot Alias a path to itself, and if you Alias "/", then that means that all URL-paths requested from your server will be affected; In the case of you modifications, only the first Alias will ever be applied, because it matches *all* requests from your server. The second Alias will never be applied.

Do yourself a favor, and install it exactly as they specified, and get it working that way first. You will then have overcome almost all obstacles to running the software on your server -- Not always a trivial task.

After getting it working, you can then make modifications, and if something breaks, you will then be sure that your change caused the problem.

Be aware that using 'friendly URLs' is a two-step process. First, the links on pages seen in a browser must reference the friendly URLs (only), and then you use mod_alias and/or mod_rewrite to 'map' those friendly URLs, when requested from your server, to the actual filepaths where the content for those URLs is located.

Keep in mind that using mod_alias and/or mod_rewrite means that the relationship between a URL and a filepath on your server is not longer a direct one; Either module can be used to map *any* URL to *any* Web-accessible filepath on your server, and URLs and filepaths are not the same thing.

Also, do not refer to index.php in any on-page link, and do not redirect to it; Always refer to the "home page" of your site as simply "/", and use DirectoryIndex to map that to index.php, index.html, etc. as appropriate. There is no reason to 'expose' the technology of your site (which amy change over time) by referring to index.php, and there is no reason to require people to type in those extra characters just to reach your home page.

Jim

Zoomy

3:29 am on Aug 26, 2007 (gmt 0)

10+ Year Member



Thanks for the reply. I actually have this software working for quite sometimes but my boss or rather the SEO he is hiring wants a clean URL.

By the way, pardon me for the mwuserscom and mwusers.com directory and URL that I posted in my earlier post. I just copied and pasted the same question that I posted at their forum. Sorry again.


You cannot Alias a path to itself, and if you Alias "/", then that means that all URL-paths requested from your server will be affected; In the case of you modifications, only the first Alias will ever be applied, because it matches *all* requests from your server. The second Alias will never be applied.

Do yourself a favor, and install it exactly as they specified, and get it working that way first. You will then have overcome almost all obstacles to running the software on your server -- Not always a trivial task.

I followed exactly as they specified in the manual for clean URL and it is working. The only problem is their instruction has the word "wiki" while I installed the software in the root directory not a directory called "wiki." So, how do I get rid of this wiki?

Do I have to put

Alias "/" "/var/www/webmasterworldcom/index.php"

instead of Alias / "/var/www/webmasterworldcom/index.php"?

So sorry for asking too many questions.

Anyway, many thanks. I am now trying to read the Apache manuals. I am new to this Apache server configuration and looking at the manuals for the first time I am astonished at all the stuffs I could do with my Apache server.

wheelie34

9:22 am on Aug 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



About 2 months ago I did a mediawiki install for someone, heres the changes I did for the short seo URL's to work

localsetting.php

$wgArticlePath = "$wgScriptPath/$1";

htaccess

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,L]
#RedirectMatch ^/$ http://www.example.com/

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

HTH