Member Avatar for randomkid73

Hi all,

I'm having some issues with RewriteRules conflicting in my .htacccess file. For starters, here's the file:

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On

#Start forum rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(jpeg|jpg|gif|png)$ /public/404.php [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

#Start wiki rules
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?$ %{DOCUMENT_ROOT}/w/index.php [L]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2 [L,QSA,B]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]
</IfModule>

I'm running a forum (IPBoard) and a wiki (Mediawiki) and both have basically the same goals. The forum uses friendly URLs by removing index.php to make http://example.com/topic/1234-topic-title and the wiki uses a rewrite to turn http://example.com/w/index.php?title=Article_Title into http://example.com/wiki/Article_Title.

The rules seem to be conflicting in their current state, however. Most of my experience lies with IIS on windows, so .htaccess is a bit new to me. All of these directives are copied from the respective applications. Thanks for your help.

Member Avatar for randomkid73

I was able to fix the issue on my own after a little research and creative (to me) thinking.

I added RewriteCond %{REQUEST_URI} !^/wiki to the forum rules, so they won't be applied if the url contains /wiki.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.