Mobile app version of vmapp.org
Login or Join
Sent6035632

: How to create Short URL in Mediawiki without getting an 403 Forbidden Error in Apache? How to create Short URL in Mediawiki without getting an 403 Forbidden Error in Apache? My httpd.conf:

@Sent6035632

Posted in: #Apache2 #Htaccess #Mediawiki

How to create Short URL in Mediawiki without getting an 403 Forbidden Error in Apache?


My httpd.conf:

#### Wikibase (BETA)
<VirtualHost *>
ServerName wikibase.isc
ServerAlias wikibase.isc
ServerAdmin SuriyaaKudoIsc@users.noreply.github.com
DocumentRoot "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase"
</VirtualHost>



My MediaWiki's local project name is "wikibase" (with a local dns adress: wikibase.isc/).

I use following code for the LocalSettings.php file (located in C:ServerApache24htdocsinc.iscfarmmediawikiwikibasew):

$wgScriptPath = "/w";
$wgServer = "http://wikibase.isc";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/";
$wgUsePathInfo = true;


I also create an .htaccess file in C:ServerApache24htdocsinc.iscfarmmediawikiwikibase:

## www.mediawiki.org/wiki/Manual:Short_URL/Apache
# Enable the rewrite engine
RewriteEngine On

# Short url for wiki pages
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]




I get an 403 Forbidden Error in my Firefox Browser from my local Apache Server 2.4:

Forbidden

You don't have permission to access /C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/index.php on this server.




EDIT:

My new httpd.conf code:

#### Wikibase (BETA)
<VirtualHost *>
ServerName wikibase.isc
ServerAlias wikibase.isc
ServerAdmin SuriyaaKudoIsc@users.noreply.github.com
DocumentRoot "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase"
</VirtualHost>
<Directory "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/wiki/">
Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>


My Apache server.log file:

[Sun Jan 10 14:40:47.547054 2016] [core:error] [pid 6260:tid 1052] (20023)The given path was above the root path: [client 127.0.0.1:8634] AH00127: Cannot map GET / HTTP/1.1 to file
[Sun Jan 10 14:40:49.665828 2016] [core:error] [pid 6260:tid 1052] (20023)The given path was above the root path: [client 127.0.0.1:8634] AH00127: Cannot map GET / HTTP/1.1 to file
[Sun Jan 10 14:40:51.601607 2016] [core:error] [pid 6260:tid 1052] (20023)The given path was above the root path: [client 127.0.0.1:8634] AH00127: Cannot map GET / HTTP/1.1 to file


My Apache access.log file:

127.0.0.1 - - [10/Jan/2016:14:40:49 +0100] "GET / HTTP/1.1" 403 381
127.0.0.1 - - [10/Jan/2016:14:40:49 +0100] "GET / HTTP/1.1" 403 381 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0"
127.0.0.1 - - [10/Jan/2016:14:40:51 +0100] "GET / HTTP/1.1" 403 381
127.0.0.1 - - [10/Jan/2016:14:40:51 +0100] "GET / HTTP/1.1" 403 381 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0"




Other resources

These resources were not helpful:

www.mediawiki.org/wiki/Manual:Short_URL https://stackoverflow.com/questions/21457590/how-to-create-short-url-in-mediawiki

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Sent6035632

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sent6035632

Solved it!

It's important to use Alias and Require all granted in httpd.conf!




The httpd.conf file:



This is the configuration of the Apache Sever 2.4!


#### Wikibase (BETA)
<VirtualHost *>
ServerName wikibase.isc
ServerAlias wikibase.isc
ServerAdmin SuriyaaKudoIsc@users.noreply.github.com
DocumentRoot "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/"
Alias /wiki C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/index.php
Alias /wiki/index.php C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/index.php
Alias /wiki/load.php C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/load.php
Alias /wiki/api.php C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/api.php
Alias /wiki/opensearch_desc.php C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/opensearch_desc.php
Alias /wiki/skins C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/skins
Alias /wiki/images C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/images
</VirtualHost>
Include "conf/wikibase-htaccess.conf"





The LocalSettings.php file:



This is the wiki setting file!


$wgScriptExtension = ".php";
$wgScriptPath = "/w";
$wgArticlePath = "/wiki/";
$wgUsePathInfo = true;





The wikibase-htaccess.conf file:



This file is included in httpd.conf!


# MediaWiki & Stackoverflow
#<Directory "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/">
# Options None
# AllowOverride None
# Order allow,deny
# Allow from all
# SSLRequireSSL
# SSLRequire %{SSL_CLIENT_S_DN} =~ m/.*serialNumber=<personnummer>$/
#</Directory>
<Directory "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/">
Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>

# Source: wiki.bitnami.com/Components/Apache/htaccess_configuration <Directory "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/cache">
Deny from all
</Directory>
<Directory "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/images">
# Protect against bug 28235
<IfModule rewrite_module>
RewriteEngine On
RewriteCond %{QUERY_STRING} .[^/:*?x22<>|%]+(#|?|$) [nocase]
RewriteRule . - [forbidden]
</IfModule>
</Directory>
<Directory "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/includes">
Deny from all
</Directory>
<Directory "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/languages">
Deny from all
</Directory>
<Directory "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/maintenance">
Deny from all
</Directory>
<Directory "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/maintenance/archives">
Deny from all
</Directory>
<Directory "C:/Server/Apache24/htdocs/inc.isc/farm/mediawiki/wikibase/w/serialized">
Deny from all
</Directory>





The .htaccess file:



In the .htaccess file there are two possible working methods!


###################### 1st Method (currently used) #########################

## www.mediawiki.org/wiki/Manual:Short_URL/Apache
# Enable the rewrite engine
RewriteEngine On

# Short url for wiki pages
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]


###################### 2nd Method (deactivated) #########################

# Enable the rewrite engine
##RewriteEngine On
##RewriteBase /wiki

# Redirect index.php to non index.php
##RewriteCond %{THE_REQUEST} ^[A-Z]{3,} /(.*)index.php
##RewriteRule ^ %1? [R=301,L]

# Internally rewrite request to index.php
##RewriteCond %{REQUEST_FILENAME} !-f
##RewriteCond %{REQUEST_FILENAME} !-d
##RewriteRule ^(.*)$ index.php?/ [L]

10% popularity Vote Up Vote Down


 

@BetL925

When you encounter a 403 forbidden error it usually is a problem with directory permissions rather than with .htaccess files and rewrite rules.

The first step is to check your servers error log. The error log often has more information in it than is presented to the user's web browser.

The other thing to try is to check the directory permissions. Make sure that the user Apache is running as has permissions to read and execute index.php in that directory.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme