-
Mod Rewrite Help
Good evening!
I was wondering if I could get a little help with my .htaccess file, trying to get the VaultWiki URL format changed (I would be fine with either of the non-default options).
Here is my current .htaccess file - I am using vBulletin's suggested values for their own "friendly URLs", and I am not sure where to place the VaultWiki edits. At this point, it returns a 404 error, I'm not sure if the placement in the file makes a difference? I don't understand the mod rewrites very well, so thank you in advance for your patience!
PHP Code:
RewriteEngine on
# If you are having problems or are using VirtualDocumentRoot, uncomment this line and set it to your vBulletin directory.
RewriteBase /
# If you are having problems with the rewrite from content/ to content.php, uncomment this line to turn MultiViews off.
Options -MultiViews
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# Forum
RewriteRule ^threads/.* showthread.php [QSA]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^members/.* member.php [QSA]
RewriteRule ^blogs/.* blog.php [QSA]
RewriteRule ^entries/.* entry.php [QSA]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# MVC
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]
# Check MVC result
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ - [NC,L]
RewriteRule ^(.*)$ - [R=404,L]
# VaultWiki from: https://www.vaultwiki.org/manual/vaultwiki-4-manual/vw4:rewrite-configuration
# If filename is not 'wiki_index', replace WIKI_FILE and uncomment the following line
# RewriteRule ^WIKI_FILE.php wiki_index.php [L,QSA]
# If URL format is /wiki/path or replaces a catch-all rule, uncomment the following 3 lines
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)?$ wiki_index.php [L,QSA]
This is with the new 4.0.0 Alpha 2. I've been a customer for years, and I love the new version, thank you guys for your work on it!!
-
Remove this line:
Code:
RewriteRule ^(.*)$ - [R=404,L]
That was sending the script to 404 before it even reached the VaultWiki block. Since the earlier catch-all rule doesn't have the L (location) flag, I don't think we need to worry about the path being unreadable by VaultWiki, but if you find yourself getting 404s on existing wiki pages, then you may need to add this to the beginning of the VaultWiki rules too:
Code:
RewriteRule ^(.+)\.php\?r=(.*)$ $1/$2 [QSA]
-
Thank you very much, that did the trick!!
-
Did you need to do both changes or just the first one? I would like to update our manual on this subject so please let me know.
-
I only removed the first code. I added the other line of code, but commented it out, just in case.
Here is my full htaccess, in case it helps (I commented in a few things, which may not be helpful to others, but I like to remember where I got the code from!):
PHP Code:
RewriteEngine on
# If you are having problems or are using VirtualDocumentRoot, uncomment this line and set it to your vBulletin directory.
RewriteBase /
# If you are having problems with the rewrite from content/ to content.php, uncomment this line to turn MultiViews off.
Options -MultiViews
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# Forum
RewriteRule ^threads/.* showthread.php [QSA]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^members/.* member.php [QSA]
RewriteRule ^blogs/.* blog.php [QSA]
RewriteRule ^entries/.* entry.php [QSA]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# MVC
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]
# Check MVC result
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ - [NC,L]
# Removed per https://www.vaultwiki.org/threads/5508/#post14909
# RewriteRule ^(.*)$ - [R=404,L]
# VaultWiki from: https://www.vaultwiki.org/manual/vaultwiki-4-manual/vw4:rewrite-configuration
# If filename is not 'wiki_index', replace WIKI_FILE and uncomment the following line
# RewriteRule ^WIKI_FILE.php wiki_index.php [L,QSA]
# Per https://www.vaultwiki.org/threads/5508/#post14909
# If getting 404 on existing wiki pages, uncomment this line:
# RewriteRule ^(.+)\.php\?r=(.*)$ $1/$2 [QSA]
# If URL format is /wiki/path or replaces a catch-all rule, uncomment the following 3 lines
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)?$ wiki_index.php [L,QSA]