Jump to content

Apache ReWrite Rules .HTACCESS FILE


Erudes

Recommended Posts

Hey everyone, new to the forum hope I'm posting in the right place.

I have MediaWiki installed on Apache on CentOS7. Everything works fine, but I need to rewrite URLs to make them shorter. Default path is http://mediawiki.my.domain/mediawiki/index.php/article, and I'm just trying to get them like this: http://mediawiki.my.domain/mediawiki/article

I edited LocalSettings.php on MediaWiki path with:

$wgScriptPath = "/mediawiki";
$wgArticlePath = "/mediawiki/$1";

And I also have and .htaccess file on /var/www/html with the following:

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

So when I type http://mediawiki.my.domain/mediawiki I get a 404 Not Found

The requested URL /mediawiki/Main_Page was not found on this server.

Any ideas on what I'm doing wrong?

Link to comment
Share on other sites

Well the error is: The requested URL /mediawiki/Main_Page was not found on this server.

So I'll guess the server is the one who can't display it for some reason.

Yeah, I'm following those instructions but can't seem to find what I'm missing...

I replaced /w and /wiki with /mediawiki which is my mediawiki directory.

Access Logs show this:

10.8.150.142 - - [24/Feb/2020:09:01:06 -0500] "GET /mediawiki/ HTTP/1.1" 301 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [24/Feb/2020:09:01:07 -0500] "GET /mediawiki/Main_Page HTTP/1.1" 404 217 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [24/Feb/2020:09:01:07 -0500] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:08:47:49 -0500] "GET /mediawiki/%7D HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:08:47:49 -0500] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:08:47:53 -0500] "GET /mediawiki/ HTTP/1.1" 301 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:08:47:55 -0500] "GET /mediawiki/Main_Page HTTP/1.1" 404 217 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:08:47:56 -0500] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:08:48:06 -0500] "GET / HTTP/1.1" 200 130 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:08:48:06 -0500] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:08:48:11 -0500] "GET /mediawiki/ HTTP/1.1" 301 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:08:48:11 -0500] "GET /mediawiki/Main_Page HTTP/1.1" 404 217 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:08:48:11 -0500] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:09:07:37 -0500] "GET /mediawiki/ HTTP/1.1" 301 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:09:07:38 -0500] "GET /mediawiki/Main_Page HTTP/1.1" 404 217 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
10.8.150.142 - - [25/Feb/2020:09:07:38 -0500] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"

Any thoughts?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.