Solved: 9 Years, 2 Weeks ago Need some guidance on rewrite rules or maybe other suggestions on what to do
#1
Solved: 9 Years, 2 Weeks ago
Quote:What I've managed to do
I've finally found the rules i need to have in my .htacces files in order to write http://agentc0re.com/agentc0re/forum/* to http://agentc0re.com/Forum/*  It's great and all but doesn't quite work.
Visually it works, mechanically it doesn't.  For example, when I login and it redirects me back the index or portal page, it's as if i never logged in.  BUT if i browse to the non rewritten form, I am indeed logged in.

Quote:Magic rewrite rules that did it all


    ####  Forum Rewrite Rules ####

    RewriteRule ^Forum/(.*)$ /agentc0re/forum/$1 [L]
    RedirectMatch 302 ^agentc0re/forum/(.*)$ http://agentc0re.com/Forum/$1
These rules are place one level below for forum directory.  Although it doesn't matter if they are here or there.  Same thing happens.
Also here is my directory structure.
public_html
    agentc0re
        forum
        blog
        etc..
    other domains

Quote:One last weird issue
So when you first visit my site at http://agentc0re.com/Forum and then hover over the category/forum links, you will notice that only those two lack the "/Forum/" in between them.  I have no clue why. 
Let me know if i need to provide you with further information.
Thanks!
-Jon
Reply
#2
Solved: 9 Years, 2 Weeks ago
(2015-11-24, 04:26 PM)agentc0re Wrote: For example, when I login and it redirects me back the index or portal page, it's as if i never logged in.  BUT if i browse to the non rewritten form, I am indeed logged in.
Update the Cookie Path (Site Details) to reflect the resulting path (/forum/).

Quote:So when you first visit my site at http://agentc0re.com/Forum and then hover over the category/forum links, you will notice that only those two lack the "/Forum/" in between them.  I have no clue why.
They seem to be relative, so you would need to add another rule to redirect from /forum to /forum/ (forcing the trailing slash).
devilshakerz.com/pgp (DF3A 34D9 A627 42E5 BC6A 6750 1F2F B8AA 28FF E1BC) ▪ keybase.io/devilshakerz
Reply
#3
Solved: 9 Years, 2 Weeks ago
Thank so much, it was the cookie path indeed for that issue.  It works perfectly now.

The rewrites for those two odd paths, well im either rewriting them improperlly or it's some other under lying issue.

I tried:
RedirectMatch 302 ^Forum/?$ /Forum/$1
&
RewriteRule ^Forum/?$ /Forum/ [L]
Mind you not at the same time, but it were the rules i tried one at a time.

Update
RedirectMatch 302 ^/Forum$ http://agentc0re.com/Forum/
I've also tried that.  It doesn't work either.
Reply
#4
Solved: 9 Years, 2 Weeks ago
(2015-11-24, 04:26 PM)agentc0re Wrote: These rules are place one level below for forum directory.
In public_html/agentc0re/forum/?

Do you have any other content in the same .htaccess file and the directories above?
devilshakerz.com/pgp (DF3A 34D9 A627 42E5 BC6A 6750 1F2F B8AA 28FF E1BC) ▪ keybase.io/devilshakerz
Reply
#5
Solved: 9 Years, 2 Weeks ago
Quote:My .htaccess in public_html, aka / (root)
Options +FollowSymlinks +Includes +SymLinksIfOwnerMatch +ExecCGI -MultiViews -Indexes
<files .htaccess>
   Order allow,deny
   Deny from all
</files>

ErrorDocument 404 /agentc0re/404/index.html

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.agentc0re.com$ [NC]
RewriteRule ^(.*)$ http://agentc0re.com/$1 [R=301,L,NC]

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.agentc0re.com$ [NC]
RewriteRule ^(.*)$ https://agentc0re.com/$1 [R=301,L,NC]

RewriteCond %{HTTP_HOST} ^(www.)?agentc0re.com$ [NC]
RewriteCond %{REQUEST_URI} !^/agentc0re/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /agentc0re/$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?agentc0re.com$ [NC]
RewriteRule ^(/)?$ agentc0re/index.php [L]
</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>

Quote:.htaccess in /agentc0re <-pseudo root
Options +FollowSymlinks +Includes +SymLinksIfOwnerMatch +ExecCGI -MultiViews -Indexes
<files .htaccess>
   Order allow,deny
   Deny from all
</files>

<IfModule mod_rewrite.c>
    RewriteEngine On

    #### agentc0re Rewrite Rules ####

    RewriteBase /agentc0re/

    RewriteRule ^Home/?$ /index.php?page= [L]
    RewriteRule ^Blog/?$ /index.php?page=blog [L]
    RewriteRule ^Forum/?$ /index.php?page=forum/index [L]
    RewriteRule ^Sub_Counter/?$ /index.php?page=SubCounter/subCounter [L]
    RewriteRule ^AboutMe/?$ /index.php?page=aboutme [L]
    RewriteRule ^Contact/?$ /index.php?page=contact [L]

    #### Blog Rewrite Rules ####

    RewriteBase /agentc0re/blog/
    RewriteRule ^index\.php$ - [L]
    RewriteBase /agentc0re/blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^Blog/(.*)$ ../index.php?page=blog [L,NC]

    RewriteCond %{REQUEST_URI} !^/agentc0re/blog/.*$
    RewriteRule ^Blog/(.*)$ /agentc0re/blog/$1 [L]

    ####  Forum Rewrite Rules ####

    #Redirect 302 Forum/ /Forum/
    RewriteRule ^Forum/(.*)$ /agentc0re/forum/$1 [L]
    RedirectMatch 302 ^agentc0re/forum/(.*)$ http://agentc0re.com/Forum/$1

    #RedirectMatch 302 ^/Forum$ http://agentc0re.com/Forum/
    #RewriteRule ^/?$ /Forum/ [L]

    #RewriteRule ^/agentc0re/forum/(.*)$ /Forum/$1 [L]
    #RedirectMatch 302 ^/Forum/(.*)$ http://agentc0re.com/agentc0re/forum/$1

    #### Forum Rewrite SEO Rules ####

#    RewriteBase /agentc0re/forum/
#
#	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 application/x-javascript text/css text/html text/xml
</IfModule>
And then everything in /agentc0re/forum is pretty much commented out.  I am not doing any SEO rules until i figure this out.

If anything doesn't make sense, let me know & i'll try to make sense of it. Big Grin
-Jon
Reply
#6
Solved: 9 Years, 2 Weeks ago
Change
RewriteRule ^Forum/?$ /index.php?page=forum/index [L]
to
RewriteRule ^Forum/$ /index.php?page=forum/index [L]
in the second file; that will allow consecutive rules matching /Forum (without trailing slash) to be parsed as well ([L] is preventing that).

Next, try the redirection again:
RedirectMatch 302 ^/Forum$ /Forum/
devilshakerz.com/pgp (DF3A 34D9 A627 42E5 BC6A 6750 1F2F B8AA 28FF E1BC) ▪ keybase.io/devilshakerz
Reply
#7
Solved: 9 Years, 2 Weeks ago
So turns out the last issue is a theme issue. I have to go through and mark certain areas to be '/Forum/whatever.php' instead of their default 'whatever.php'

Im learning a lot about mybb, thats for sure. Big Grin

Question about that. Should I use '/Forum/whatever.php' or should i use '{$mybb->settings['bburl']}/whatever.php' ?

Both accomplish the same but is there a resource difference or maybe just proper way to do it one way or the other?
Reply
#8
Solved: 9 Years, 2 Weeks ago
It's recommended to use the variable so that when the forum's address changes it doesn't need to be replaced in templates.
devilshakerz.com/pgp (DF3A 34D9 A627 42E5 BC6A 6750 1F2F B8AA 28FF E1BC) ▪ keybase.io/devilshakerz
Reply
#9
Solved: 9 Years, 2 Weeks ago
(2015-11-24, 07:50 PM)Devilshakerz Wrote: Change
RewriteRule ^Forum/?$ /index.php?page=forum/index [L]
to
RewriteRule ^Forum/$ /index.php?page=forum/index [L]
in the second file; that will allow consecutive rules matching /Forum (without trailing slash) to be parsed as well ([L] is preventing that).

Next, try the redirection again:
RedirectMatch 302 ^/Forum$ /Forum/


When i remove the ? from the RewriteRule then i get a 404 for the site.
Also about the "{$mybb->settings['bburl']}" in templates makes more sense when you put it that way.  Thank you very much for your help!
Reply
#10
Solved: 9 Years, 2 Weeks ago
(2015-11-24, 07:52 PM)agentc0re Wrote: So turns out the last issue is a theme issue.  I have to go through and mark certain areas to be '/Forum/whatever.php' instead of their default 'whatever.php'

Im learning a lot about mybb, thats for sure.  Big Grin

Question about that.  Should I use '/Forum/whatever.php' or should i use '{$mybb->settings['bburl']}/whatever.php' ?

Both accomplish the same but is there a resource difference or maybe just proper way to do it one way or the other?

If you hard code like this: /Forum/whatever.php

and then change the setting {$mybb->settings['bburl']} in admin, you're going to notice a problem, and then have to look for all your hard coded links. That would be my reason for not using /Forum/whatever.php
What goes around comes around
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)