Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I hate htaccess.
Author Message
Josh
Member


Posts: 94
Joined: Jul 2008
Reputation: 0
Thanked 0 Times in 0 Posts
MyBux: 70
Post: #1
I hate htaccess.

So I'm trying to edit MyBB's htaccess file to show my forums, threads, posts, and users like this:
http://domain.com/threads/1/
http://domain.com/threads/1/post/1/
http://domain.com/users/1/
http://domain.com/forum/1/

I've got it all pretty much working except the posts URL and the trailing forward slash. Those aren't working right. The posts URL brings a 404 error and so does a trailing forward slash.

Man, I hate htaccess. Now I know why I've never bothered to edit it. >.>

Code:
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>
    RewriteRule ^calendar-([0-9]+)\.html$ calendar.php?calendar=$1 [L,QSA]
    RewriteRule ^calendar-([0-9]+)-year-([0-9]+)\.html$ calendar.php?action=yearview&calendar=$1&year=$2 [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 application/x-javascript text/css text/html text/xml
</IfModule>

  Options +FollowSymLinks
  RewriteEngine On

  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteCond %{SCRIPT_FILENAME} !-f

  RewriteRule ^users/(\d+)*$ ./member.php?action=profile&uid=$1
  RewriteRule ^threads/(\d+)*$ ./showthread.php?tid=$1
  RewriteRule ^announcements/(\d+)*$ ./announcements.php?aid=$1
  RewriteRule ^forum/(\d+)*$ forumdisplay.php?fid=$1
  RewriteRule ^forum/page/(\d+)*$ forumdisplay.php?fid=$1&page=$2
  RewriteRule ^threads/$1/page/$2/(\d+)*$ showthread.php?tid=$1&page=$2
  RewriteRule ^threads/$1/lastpost/(\d+)*$ showthread.php?tid=$1&action=lastpost
  RewriteRule ^threads/$1/nextnewest/(\d+)*$ showthread.php?tid=$1&action=nextnewest
  RewriteRule ^threads/$1/nextoldest/(\d+)*$ showthread.php?tid=$1&action=nextoldest
  RewriteRule ^threads/$1/newpost/(\d+)*$ showthread.php?tid=$1&action=newpost
  RewriteRule ^threads/$1/post/$2/(\d+)*$ showthread.php?tid=$1&pid=$2

08-01-2009 12:36 PM


MattR
Sitting in Jacob's Cabin


Posts: 54
Joined: Oct 2008
Reputation: 0
Thanked 0 Times in 0 Posts
MyBux: 140
Post: #2
RE: I hate htaccess.

I've only just figured out mod_rewrite myself but give this a go... I don't know what the (\d+) bit means so I'll put in what I used, see if it works, that bit can always be changed after...

Code:
RewriteRule ^users/([^/.]+)/?$ ./member.php?action=profile&uid=$1
RewriteRule ^threads/([^/.]+)/?$ ./showthread.php?tid=$1
RewriteRule ^announcements/([^/.]+)/?$ ./announcements.php?aid=$1
RewriteRule ^forum/([^/.]+)/?$ forumdisplay.php?fid=$1
RewriteRule ^forum/([^/.]+)/page/([^/.]+)/?$ forumdisplay.php?fid=$1&page=$2
RewriteRule ^threads/([^/.]+)/page/([^/.]+)/?$ showthread.php?tid=$1&page=$2
RewriteRule ^threads/([^/.]+)/post/([^/.]+)/?$ showthread.php?tid=$1&pid=$2#pid=$2

I can't figure out the lastpost/nextnewest/nextoldest bit but see if that stuff works first.

Edit: The physical URLs seem to work when I go to them directly, but there are other problems. Because you're removing the .html bit, all the images on the page will break; MyBB uses relative URLs so if a URL is ./users/1/ for example, the profile star images will be trying to load ./users/1/images/star.gif... plus, the URLs on the actual forum are still the default SEO ones, ./user-1.html etc, can't see where to change that behaviour. So, although it seems those URLs work, I don't think it's as simple as changing the rewrite rules. frostschutz knows a lot about this, there might be a chance you could use the Google SEO plugin and change the settings to get what you need.



Learn MyBB - My Blog
MyBB Support Team
(This post was last modified: 08-01-2009 09:32 PM by MattR.)
08-01-2009 08:47 PM
Josh
Member


Posts: 94
Joined: Jul 2008
Reputation: 0
Thanked 0 Times in 0 Posts
MyBux: 70
Post: #3
RE: I hate htaccess.

Hmmm okay. Thanks. I'll probably use the default MyBB SEO URLs.

08-02-2009 04:30 AM
 




New to MyBBSource?Need Assistance?
  • Mark Forums Read
  • View Forum Staff
  • Looking for a MyBB Host?




Theme created by AK-47. Find more great themes and skins at K! Dezign Web Design
Wordpress Web Design
Youtube Video Free Bet Football Betting R1s