MyBB Community Forums

Full Version: MyBB SEO/.htaccess URL Rewriting HELP!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello.
I currently have a dynamic URL
(http://mysite.x10.mx/mybb/member.php?act...file&uid=1)

And I want to switch to static URL's
(http://mysite.x10.mx/mybb/user-1.html)

Yet, all of the php I have trie in my .htaccess in the root of my site (/public_html/.htaccess "is the location of my file") And my forum install (MyBB) is located in: (public_html/mybb/). So, can someone please tell me, to change to static url's, what code do I have to put into my .htaccess for my url's to work as static url's? I get a 404 error when I try one of these:


Options +Multiviews 

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} !mod= [NC]
RewriteRule ^([^/]+)$ /index.php?mod=$1 [L]


Please help.
There's an example .htaccess file included in MyBB (htaccess.txt).
Didn't work. Bump
First off, delete that .htaccess of yours. It's not gonna work. Afterwards you need to rename the htaccess.txt file to .htaccess and go to Admin CP > Configuration > Settings > Server and Optimization Options > Enable search engine friendly URLs? > Enabled.
(2011-07-21, 10:31 PM)faviouz Wrote: [ -> ]First off, delete that .htaccess of yours. It's not gonna work. Afterwards you need to rename the htaccess.txt file to .htaccess and go to Admin CP > Configuration > Settings > Server and Optimization Options > Enable search engine friendly URLs? > Enabled.

please help me .
(2011-07-21, 10:31 PM)faviouz Wrote: [ -> ]First off, delete that .htaccess of yours. It's not gonna work. Afterwards you need to rename the htaccess.txt file to .htaccess and go to Admin CP > Configuration > Settings > Server and Optimization Options > Enable search engine friendly URLs? > Enabled.

Faviouz, I did that... An it didn't work. My MyBB folder is in public_html/mybb/ would I maybe have to change any links out of this 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> 
    RewriteEngine on 
        RewriteBase /  
    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]+)\.html$ calendar.php?action=yearview&calendar=$1&year=$2 [L,QSA] 
No, the file is fine. Did you enable the setting in the Admin CP too?
(2011-07-21, 10:46 PM)faviouz Wrote: [ -> ]No, the file is fine. Did you enable the setting in the Admin CP too?

Yes. But I just get a 404 error when I click on a thread or user, the message says:

Not Found

The requested URL /mybb/forum-1.html was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Where did you get that? Looks a bit outdated. Replace the .htaccess file with this:

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]+)\.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/javascript text/css text/html text/xml
</IfModule>
(2011-07-21, 11:01 PM)faviouz Wrote: [ -> ]Where did you get that? Looks a bit outdated. Replace the .htaccess file with this:

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]+)\.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/javascript text/css text/html text/xml
</IfModule>
Now, that give me a 500 internal server error...
If this helps, my hostin is x10hosting.com on the stoli server...
And my MyBB isnt installed actually in the root, all of my files are in this directory: public_html/MyBB/(all of my MyBB files are here, such as the admin directory and other stuff).
Pages: 1 2