Posted August 29, 20186 yr So a long time ago when I set up IPB, I likely followed some guide that recommended I install forums in a /forums/ subdirectory. A decade has passed, and my site still lives at domain.com/forums and the files are installed in /forums/. I have a permanent redirect set up as follows in the root domain.com folder to redirect to /forums/ and also strip the www from the domain: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301] RewriteRule ^$ /forums [R=301,NC,L] I want to do two moves now: Move my install from /forums/ to root. Force https. I want to follow best SEO practices so that all existing links remain valid and end up at the right place. Per this post: it sounds like I may run into some issues with the fact my subdirectory is /forums/ (although I notice that even on this site, urls are /forums/forum (which is what I wanted to get rid of). Is there a best way to accomplish this?
August 29, 20186 yr This can be a little confusing as it would depend on what your default app is, in your case, it's forums, so you should be able to use the following htaccess file inside a folder named /forums to allow everything to work properly. Options +FollowSymLinks RewriteEngine On redirect 301 /forums https://mysite.com Removing the htaccess you have in the root also, no need to force the removal of www or ssl (if using ssl) as it will pick this up from your conf file.
August 29, 20186 yr Author Thanks @Rhett. Am I correct in understanding that if forums is my default app installed in root, it will remove the /forums/ slug from the URL, but if I made say pages the default app, and still had my install in the root, it would add back the /forums/ slug due to forums not being the default? All of the above is fine behavior - what I am trying to avoid is moving my install from an actual /forums/ subdirectory to root but having all existing links break if the /forums/ part of the url disappears when I make forums the default. Once I make the move, my assumption is that if someone clicks an existing friendly url link to http://domain.com/forums/topic/12345-example-topic, it will know to load https://domain.com/topic/12345-example-topic and not throw a 404 not found. Edited August 29, 20186 yr by Morgin
August 29, 20186 yr Author As an aside, I’m abstracted away from my Apache .conf, so I believe I will need to strip www and force https in the .htaccess file in root. Without it, www and non-www both work and http and https both work as links. I want only https and non-www to display in the browser url bar. This seems much easier to implement however if I don’t need to specifically address links with /forums/ aside from your .htaccess code for such directory above (and I presume that if I made pages the default, I could just delete the forums subdirectory and drive on as none of the links would change.) 10 minutes ago, Rhett said: That is correct, if you have any trouble let me know. 👍 Thanks again!
August 30, 20186 yr Author Posting for future reference for myself and anyone else this helps - My combined .htaccess with friendly URL, forcing non-www, and forcing https: RewriteEngine On # match any URL with www and rewrite it to https without the www RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC] RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301] # match urls that are non https (without the www) RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^(www\.)(.*) [NC] RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Invision Community Friendly URLs RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] Also, if anyone out there wanted to take a stab at converting these to appropriate .conf format (or critiquing them), it turns out that would in fact be very appreciated! Edited August 30, 20186 yr by Morgin
August 30, 20186 yr You don't need this portion as mentioned when using Invision, it will use whatever url is in your conf file. no need for these redirects. # match any URL with www and rewrite it to https without the www RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC] RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301] # match urls that are non https (without the www) RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^(www\.)(.*) [NC] RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
August 30, 20186 yr Author 1 hour ago, Rhett said: You don't need this portion as mentioned when using Invision, it will use whatever url is in your conf file. no need for these redirects. # match any URL with www and rewrite it to https without the www RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC] RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301] # match urls that are non https (without the www) RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^(www\.)(.*) [NC] RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] When I was testing last night, as soon as I removed this I was able to access my site over http and with a www in the url, notwithstanding my conf_global url was set to https://domain.com. I wonder if my own server setup is forcing that to be accepted absent the rewrites above. Thanks for flagging that either way, I’ll look into this more.
August 30, 20186 yr 1 hour ago, Morgin said: When I was testing last night, as soon as I removed this I was able to access my site over http and with a www in the url, notwithstanding my conf_global url was set to https://domain.com. I wonder if my own server setup is forcing that to be accepted absent the rewrites above. Thanks for flagging that either way, I’ll look into this more. Submit a ticket and I would be happy to review if needed.
August 30, 20186 yr Author 14 minutes ago, Rhett said: Submit a ticket and I would be happy to review if needed. Will do (and for reference, apache.conf and doing the rewrites in the <directory> settings therein is what I thought you were originally talking about above - it all makes more sense now that I know you meant conf_global 😂)
Archived
This topic is now archived and is closed to further replies.