MyBB Community Forums

Full Version: Google SEO: how to combine forced HTTPS and SEO url rewriting with IDs
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys Cool


I use this config to force HTTPS and the www (URL rewriting deactivated for now):

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.mydomain.tld/$1 [L,QSA,R=301]

[...]
</IfModule>

Google SEO plugin works fine on my setup, but without this previous config. These only operate independently.
I would like to know if this config can be combined with first rule of Google SEO?

RewriteRule ^([^&]*)&(.*)$ https://www.mydomain.tld/$1?$2 [L,QSA,R=301]

I don't understand this rule and I have trouble with .htaccess language... Sad


In regards to SEO URL rewriting: is it possible to keep IDs (fid, tid, uid) in URIs?
  • mydomain.tld/f1234_forum-title
  • mydomain.tld/t1234_thread-title
  • mydomain.tld/u1234_username
  • etc.

Like this if a title/name is changed, I hope that link remains findable with unique ID of element.
In this way in case of:
  • wrong URI: mydomain.tld/t111_old-thread-title -> mydomain.tld/t111_actual-thread-title
  • incomplete URI: mydomain.tld/t111 -> mydomain.tld/t111_actual-thread-title


Thanks in advanced for help! Smile
I've added this to my .htaccess file and it works fine.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://amxmodx-es.com/$1 [R=301,L]

I also have Google SEO plugin.

Note: The rewrites above are the lasts rules of my htaccess.
Ok, but you don't have rule for search highlighting (with two parameters)? It works anyway?

Google SEO default rule (must be first in htaccess):

RewriteRule ^([^&]*)&(.*)$ https://www.mydomain.tld/$1?$2 [L,QSA,R=301]
(2016-10-27, 11:33 AM)verspax Wrote: [ -> ]
RewriteRule ^([^&]*)&(.*)$ https://www.mydomain.tld/$1?$2 [L,QSA,R=301]

I don't understand this rule and I have trouble with .htaccess language... Sad

It's an ugly workaround. It converts Thread-subject&highlight (a broken link) to Thread-subject?highlight.

MyBB is not prepared for alternative URL styles. It blindly appends "?highlight=" or "&highlight=" (depending on which MyBB URL style you chose) so instead of Thread-subject?highlight=xyz you might get Thread-subject&highlight=xyz which won't work w/o the rewrite above. (Or in extended form, you also get Thread-subject?something=else?highlight=xyz). highlight is just an example, it also happens with other parameters.

This is because MyBB does not have a function like url_append($url, "another=parameter") that would figure out what's the right thing to do, it simply assumes either or the other will just fit, which works for MyBB core, but not for plugins that change URL styles.

The example you showed would also redirect to https (and to www.), but it sounds like that's what you wanted to do anyway, so there shouldn't be a problem. It would be a lot more complicated if you didn't want it to redirect...

Keeping IDs in URLs is possible with the "force uniquifier" option.

Quote:Like this if a title/name is changed, I hope that link remains findable

Changing titles does not break URLs. Google SEO remembers the old names and redirects them. And forcing IDs would not help keep them working, not unless you ALSO change all the rewrite rules to just rewrite the IDs directly as the original MyBB rules do.

Even though Google SEO may sometimes use an ID in its URLs (to avoid same name conflicts), technically it's still just a name and looked up by name, not by ID.
Here is what I did and put it as the first rule and it works perfect


# Google SEO workaround for search.php highlights:
RewriteCond %{HTTPS} off
# Make this rule the first rewrite rule in your .htaccess!
RewriteRule ^([^&]*)&(.*)$ https://www.site.com/$1?$2 [L,QSA,R=301]