MyBB Community Forums

Full Version: htaccess issues with forum in subdirectory
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello....

---- I have a domain: example.com , and I have more than one forum configured as such: 
example.com/photon
example.com/gluon
example.com/muon


----- Whenever I have a .htaccess file in the public_html folder, NO MATTER WHAT IS IN IT, just the presence of one, makes the forums at "/photon/" etc go completely blank. 

Current htaccess in the "public_html"
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php70” package as the default “PHP” programming language.
<IfModule mime_module>
  AddType application/x-httpd-ea-php70 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
 
Which is just easy apache popping that in there. 

---- I want to have an https rewrite condition in my public_html htaccess file, but I cannot even have one and have the forums remain useful. 

--- When I click "view pagesource" on the forum "/photon", this is what is in the page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Please help!
This is an old thread I know but I am also coming across this issue.

Bumping to see if anyone can shed some light on this.
What is in the .htaccess file? If it's just an empty file, it might not even be configured to allow htaccess files. You'd probably better off asking your host, it'll be a server/Apache issue rather than anything to do with MyBB so we'll likely be of little help.
Hi Matt, current .htaccess file contains the following:
Options -MultiViews +FollowSymlinks -Indexes

#
# If mod_security is enabled, attempt to disable it.
# - Note, this will work on the majority of hosts but on
#  MediaTemple, it is known to cause random Internal Server
#  errors. For MediaTemple, please remove the block below
#
<IfModule mod_security.c>
 # Turn off mod_security filtering.
 SecFilterEngine Off

 # The below probably isn't needed, but better safe than sorry.
 SecFilterScanPOST Off
</IfModule>

#
# MyBB "search engine friendly" URL rewrites
# - Note, for these to work with MyBB please make sure you have
#  the setting enabled in the Admin CP and you have this file
#  named .htaccess
#
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteRule ^forum-([0-9]+)\.html$ forumdisplay.php?fid=$1 [L,QSA]
 RewriteRule ^forum-([0-9]+)-page-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2 [L,QSA]

 RewriteRule ^thread-([0-9]+)\.html$ showthread.php?tid=$1 [L,QSA]
 RewriteRule ^thread-([0-9]+)-page-([0-9]+)\.html$ showthread.php?tid=$1&page=$2 [L,QSA]
 RewriteRule ^thread-([0-9]+)-lastpost\.html$ showthread.php?tid=$1&action=lastpost [L,QSA]
 RewriteRule ^thread-([0-9]+)-nextnewest\.html$ showthread.php?tid=$1&action=nextnewest [L,QSA]
 RewriteRule ^thread-([0-9]+)-nextoldest\.html$ showthread.php?tid=$1&action=nextoldest [L,QSA]
 RewriteRule ^thread-([0-9]+)-newpost\.html$ showthread.php?tid=$1&action=newpost [L,QSA]
 RewriteRule ^thread-([0-9]+)-post-([0-9]+)\.html$ showthread.php?tid=$1&pid=$2 [L,QSA]

 RewriteRule ^post-([0-9]+)\.html$ showthread.php?pid=$1 [L,QSA]

 RewriteRule ^announcement-([0-9]+)\.html$ announcements.php?aid=$1 [L,QSA]

 RewriteRule ^user-([0-9]+)\.html$ member.php?action=profile&uid=$1 [L,QSA]

 RewriteRule ^calendar-([0-9]+)\.html$ calendar.php?calendar=$1 [L,QSA]
 RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ calendar.php?calendar=$1&year=$2&month=$3 [L,QSA]
 RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 [L,QSA]
 RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+)\.html$ calendar.php?action=weekview&calendar=$1&week=$2 [L,QSA]

 RewriteRule ^event-([0-9]+)\.html$ calendar.php?action=event&eid=$1 [L,QSA]

 <IfModule mod_env.c>
 SetEnv SEO_SUPPORT 1
 </IfModule>
</IfModule>

#
# If Apache is compiled with built in mod_deflade/GZIP support
# then GZIP Javascript, CSS, HTML and XML so they're sent to
# the client faster.
#
<IfModule mod_deflate.c>
 AddOutputFilterByType DEFLATE text/css text/html application/xhtml+xml text/xml application/xml text/plain text/x-component application/javascript application/x-javascript application/rss+xml application/atom+xml application/json application/manifest+json application/x-web-app-manifest+json application/vnd.ms-fontobject application/font-sfnt application/font-woff application/font-woff2 image/svg+xml image/x-icon
</IfModule>

# Note: You are able to choose a different name in the Admin CP. If you've done that you need to change it here too
<Files "error.log">
 Order Deny,Allow
 Deny from all
</Files>

However, when I add this to the top the website shows this page.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Interesting story my host is actually the original poster so this has been an ongoing issue for a while apparently.

Host (original poster) has also confirmed that this only happens for directories containing a MyBB installation, https rewrites work just fine for all wordpress installs they have on their VPS.
The PHP files in the directory have zero impact on a htaccess file though, it’s not how it works. Unless your MyBB forum is doing a redirect from a plugin, then MyBB has nothing to do with it.
If the .htaccess file is in public_html directory and not in the forum directory, RewriteRules are false.
(2022-02-19, 10:32 PM)Matt Wrote: [ -> ]The PHP files in the directory have zero impact on a htaccess file though, it’s not how it works. Unless your MyBB forum is doing a redirect from a plugin, then MyBB has nothing to do with it.

Makes sense lol, that's just whats happening with just MyBB installs. This one is a fresh install so no plugins however, the "Unless your MyBB forum is doing a redirect" got me thinking. I am using cloudflare so I'm wondering if perhaps that has something to do with it? The "Always Use HTTPS" setting is turned on but I noticed that from time to time someone would be able to load over http instead so I thought I also needed the .htaccess file. Maybe the settings are clashing?... I'll do some more googling and come back if I've found something in case someone else in the future comes across this issue.

(2022-02-19, 10:46 PM)Crazycat Wrote: [ -> ]If the .htaccess file is in public_html directory and not in the forum directory, RewriteRules are false.

In my case public_html is the forum directory. Smile Its not inside any particular folder for the MyBB install since I love MyBB and quite literally just use all of it for the whole site lol.
If you’ve got Cloudflare set up to force HTTPS then adding a similar rule on the forum would cause a loop, yes. Cloudflare should be forcing HTTPS before the request even reaches your server.