Posts: 1,110
Threads: 61
Joined: Sep 2008
Reputation:
31
Hi,
this is a very simple way to remove the index.php from your URL. Please note that this only works if you are running an Apache web server and mod_rewrite is enabled!
Just add the following lines to your root .htaccess file (directly after RewriteEngine On):
RewriteCond %{IS_SUBREQ} false
RewriteRule ^index.php$ http://www.example.org [R=301,L]
Of course you have to replace www.example.org wit your own MyBB installation. For example:
RewriteRule ^index.php$ http://community.mybb.com [R=301,L]
(this will work on this domain)
RewriteRule ^index.php$ http://www.example.org/board/ [R=301,L]
(if you installed MyBB in a sub folder)
The trick is the IS_SUBREQ: So the redirect will not work in sub directories like /admin or /archive (the index.php have to stay there) and it will no affect POST or GET requests!
Posts: 5
Threads: 1
Joined: Jul 2010
Reputation:
0
What a real lifesaver! I can't tell you how immensely beneficial this trick has been for me...and is going to be for everyone else looking to remove index.php from Mybb. I did that standard .htaccess 301 redirect and my forum admin section stopped working...this tricks has brought it back.
Now, the next step is to remove the references of index.php in Global template and other places.
Thank you.
Posts: 29
Threads: 1
Joined: Oct 2010
Reputation:
0
Was always wondering how to do this, thanks!
Posts: 191
Threads: 36
Joined: Dec 2007
Reputation:
0
What is the point of this?
Posts: 10,063
Threads: 311
Joined: Oct 2008
Reputation:
457
Posts: 56
Threads: 12
Joined: Oct 2010
Reputation:
0
Nice idea thank you.
Posts: 3,219
Threads: 489
Joined: Oct 2007
Reputation:
27
querschlaeger,
this works good, but it conflicts with the quick theme plugin.
when users go to switch themes using the plugin, with your modifications, it adds this to the end of the url:
?action=quicktheme
but doesn't do anything. once I removed your modification from the .htaccess, the quick theme worked as normal.
Posts: 4,392
Threads: 63
Joined: Nov 2008
Reputation:
263
This user has been denied support.
Try adding QSA
[R=301,L,QSA]
instead of [R=301,L]
That should keep the ?action=quicktheme intact.
Posts: 3,219
Threads: 489
Joined: Oct 2007
Reputation:
27
(2011-01-07, 10:31 PM)frostschutz Wrote: Try adding QSA
[R=301,L,QSA] instead of [R=301,L]
That should keep the ?action=quicktheme intact.
doing the same as before:
http://www.paforliberty.com/forum/?action=quicktheme
after modifying the .htaccess as you suggested:
RewriteEngine on
# Google SEO workaround for search.php highlights:
# Make this rule the first rewrite rule in your .htaccess!
RewriteRule ^([^&]*)&(.*)$ http://paforliberty.com/forum/$1?$2 [L,QSA,R=301]
# Google SEO Sitemap:
RewriteRule ^sitemap\-([^./]+)\.xml$ misc.php?google_seo_sitemap=$1 [L,QSA,NC]
# Google SEO URL Forums:
RewriteRule ^Forum-([^./]+)$ forumdisplay.php?google_seo_forum=$1 [L,QSA,NC]
# Google SEO URL Threads:
RewriteRule ^Thread-([^./]+)$ showthread.php?google_seo_thread=$1 [L,QSA,NC]
# Google SEO URL Announcements:
RewriteRule ^Announcement-([^./]+)$ announcements.php?google_seo_announcement=$1 [L,QSA,NC]
# Google SEO URL Users:
RewriteRule ^User-([^./]+)$ member.php?action=profile&google_seo_user=$1 [L,QSA,NC]
# Google SEO URL Calendars:
RewriteRule ^Calendar-([^./]+)$ calendar.php?google_seo_calendar=$1 [L,QSA,NC]
# Google SEO URL Events:
RewriteRule ^Event-([^./]+)$ calendar.php?action=event&google_seo_event=$1 [L,QSA,NC]
# Google SEO 404:
ErrorDocument 404 /forum/misc.php?google_seo_error=404
# Google SEO URL Forums:
RewriteRule ^forum\-([^./]+)$ forumdisplay.php?google_seo_forum=$1 [L,QSA,NC]
# Google SEO URL Threads:
RewriteRule ^thread\-([^./]+)$ showthread.php?google_seo_thread=$1 [L,QSA,NC]
# Google SEO URL Announcements:
RewriteRule ^announcement\-([^./]+)$ announcements.php?google_seo_announcement=$1 [L,QSA,NC]
# Google SEO URL Users:
RewriteRule ^user\-([^./]+)$ member.php?action=profile&google_seo_user=$1 [L,QSA,NC]
# Google SEO URL Calendars:
RewriteRule ^calendar\-([^./]+)$ calendar.php?google_seo_calendar=$1 [L,QSA,NC]
# Google SEO URL Events:
RewriteRule ^event\-([^./]+)$ calendar.php?action=event&google_seo_event=$1 [L,QSA,NC]
RewriteCond %{IS_SUBREQ} false
RewriteRule ^index.php$ http://www.paforliberty.com/forum [R=301,L,QSA]
Posts: 4,392
Threads: 63
Joined: Nov 2008
Reputation:
263
2011-01-07, 11:34 PM
(This post was last modified: 2011-01-07, 11:38 PM by frostschutz.)
This user has been denied support.
Sorry, my bad. QSA is for rewrites, not redirects...
Maybe like this:
RewriteCond %{QUERY_STRING} ^(..*)$
RewriteRule ^index\.php$ http://yoursite/mybb/?%1 [L,NS,R=301]
RewriteRule ^index\.php$ http://yoursite/mybb/ [L,NS,R=301]
Or if Apache is smart even just
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^index\.php$ http://yoursite/mybb/?%1 [L,NS,R=301]
|