• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.1 .htaccess taking over Mediawiki

Jake Bunce

XenForo moderator
Staff member
#2
Edit your XenForo .htaccess file and add the red code:

Code:
	RewriteCond %{REQUEST_FILENAME} -f [OR]
	RewriteCond %{REQUEST_FILENAME} -l [OR]
	RewriteCond %{REQUEST_FILENAME} -d
	RewriteRule ^.*$ - [NC,L]
	RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|w/) - [NC,L]
	RewriteRule ^.*$ index.php [NC,L]
That should exclude your "w" directory.
 

Jake Bunce

XenForo moderator
Staff member
#3
Well wait. If the directory exists then it should already not be handled by XenForo. I have tested and confirmed this.
 

Brentnauer

Well-known member
#5
Here are the current contents of my .htaccess. Mediawiki's bit is at the bottom:
Code:
#    Mod_security can interfere with uploading of content such as attachments. If you
#    cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
#    SecFilterEngine Off
#    SecFilterScanPOST Off
#</IfModule>

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default

<IfModule mod_rewrite.c>
    RewriteEngine On

    #    If you are having problems with the rewrite rules, remove the "#" from the
    #    line that begins "RewriteBase" below. You will also have to change the path
    #    of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|wiki/) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>

RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ /w/index.php [PT,L,QSA]
RewriteRule ^/*$ /w/index.php [L,QSA]
 

Jake Bunce

XenForo moderator
Staff member
#6
You should probably exclude w/ and wiki/ to be safe. Though I don't think it's necessary.

Then you need to add the rewrite rules for the wiki to the htaccess file. Add those rules before XenForo's rules. I am feelin this:

Code:
#    Mod_security can interfere with uploading of content such as attachments. If you
#    cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
#    SecFilterEngine Off
#    SecFilterScanPOST Off
#</IfModule>

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^/?wiki(/.*)?$ /w/index.php [PT,L,QSA]
    RewriteRule ^/*$ /w/index.php [L,QSA]

    #    If you are having problems with the rewrite rules, remove the "#" from the
    #    line that begins "RewriteBase" below. You will also have to change the path
    #    of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|wiki/|w/) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>
I am not immediately sure what the purpose of the blue line is. I might be inclined to get rid of that.
 

Brentnauer

Well-known member
#7
You should probably exclude w/ and wiki/ to be safe. Though I don't think it's necessary.

Then you need to add the rewrite rules for the wiki to the htaccess file. Add those rules before XenForo's rules. I am feelin this:

<snip>

I am not immediately sure what the purpose of the blue line is. I might be inclined to get rid of that.
No dice, both with and without the blue line :( Also causes xF to grab the page again instead of the 404 I was getting with the one I posted above.

This one has me stumped, I greatly appreciate your help so far :)

If you're willing to take a crack at it I can PM you some FTP credentials.
 

Brentnauer

Well-known member
#9
Jake is a damn genius. Not three minutes after he got FTP info he fixed it... Been cracking my skull over this for five hours now. Here's what we ended up with, in case anyone has a problem like this in the future:
Code:
#    Mod_security can interfere with uploading of content such as attachments. If you
#    cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
#    SecFilterEngine Off
#    SecFilterScanPOST Off
#</IfModule>

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^/?wiki(/.*)?$ /w/index.php [PT,L,QSA]
    RewriteRule ^/*$ /w/index.php [L,QSA]

    #    If you are having problems with the rewrite rules, remove the "#" from the
    #    line that begins "RewriteBase" below. You will also have to change the path
    #    of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|wiki/|w/) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>
Thanks again, Jake!
 

Jake Bunce

XenForo moderator
Staff member
#10
Code:
RewriteRule ^/*$ /w/index.php [L,QSA]
I didn't use that line to get it working. In fact that line interfered with XenForo.

I only added this line to the default XenForo htaccess file:

Code:
RewriteRule ^/?wiki(/.*)?$ /w/index.php [PT,L,QSA]