OK. Hopefully someone can help me with a suggestion-
I have a WordPress multisite using subfolders
I am using WooCommerce
I have a std Ubuntu 12.04/LAMP server with a GoDaddy Certificate installed
If it turn on SSL, it affects my entire domain (obviously) so my primary site ends up as:
'https://main-sitename.com'
My multisite blogs also come up as:
https://main-sitename.com/blogname-1
https://main-sitename.com/blogname-2
and so on. ALL of my menu links are also https which disables outside links because the urls all get prepended with https. :-/
What I am trying to do is get this:
http://main-sitename.com
http://main-sitename.com/blogname-1
http://main-sitename.com/blogname-2
https://main-sitename.com/shop/ (WooCommerce will force HTTPS on checkout and then un-enforce it when done).
So, Anyone have any ideas on how I can remedy this? On an interesting note, when I had the EXACT same site on Rackspace Cloud Sites everything worked fine. When I moved to a self managed Cloudserver this happened. Is there something I missed?
It sounds like SSLRequireSSL has been set for the entire server. Since you only want to enforce HTTPS on /shop/ directory. Add a .htaccess file in that directory that contains:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This will force anyone connecting to your shop with http:// to be redirected to the same URI, but on https://
EDIT 2
This works for me (with www.myserver.com changed to my real server name). I'm using date and name permalinks in WP. As soon as I go to http://www.myserver.com/shop/ I'm redirected to https. It preserves the URI.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# Addition to force redirect to https when they visit the shop!
RewriteBase /
RewriteCond %{HTTPS} !on
RewriteRule (shop/.*$) https://www.myserver.com/$1 [R=301,L]
# Back to WordPress changes
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Related
am working on wordpress. And i want to apply a redirect from www to non-www.
There is many solutions online, but non of them worked for me, maybe because htaccess in wordpress works differently?
# BEGIN WordPress
# Директивы (строки) между `BEGIN WordPress` и `END WordPress`
# созданы автоматически и подлежат изменению только через фильтры WordPress.
# Сделанные вручную изменения между этими маркерами будут перезаписаны.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^www\.eepir\.oxem\.ru [NC]
RewriteRule ^(.*)$ http://eepir.oxem.ru/$1 [L,R=302]
</IfModule>
# END WordPress
This is my code, i actually tried to post the rule outside of # BEGIN WORDPRESS but no result
Thank you.
RewriteCond %{HTTP_HOST} ^www\.eepir\.oxem\.ru [NC]
RewriteRule ^(.*)$ http://eepir.oxem.ru/$1 [L,R=302]
You've put these "redirect" directives in the wrong place. They need to go at the top of the file, before the # BEGIN WordPress section.
By placing them after the WordPress front-controller then they are never going to be processed for anything other than static resources because the request has already been routed to /index.php. At which point processing is stopped.
You should never manually edit the code between the # BEGIN WordPress and # END WordPress comment markers since this code block is maintained by WordPress itself and your changes will likely get overwritten.
... but I covered all this in your question from yesterday?
htaccess redirect 301 is working but RewriteRule is not
You also need to configure WordPress itself to use the non-www hostname. ie. WP_HOME and WP_SITEURL - which should both be set in the dashboard.
maybe because htaccess in wordpress works differently
.htaccess works the same with WordPress as anything else. .htaccess doesn't really have much to do with WordPress itself.
UDPATE: It seems www.eepir.oxem.ru has no DNS configured so the request does not even reach your server (for the redirect to occur). You need to configure the appropriate A record for www.eepir.oxem.ru in the DNS, as you have done for eepir.oxem.ru and configure your server to accept requests to www.eepir.oxem.ru (if not already). Then your redirect should work.
Hello Advanced WP'ers,
I have a WordPress multisite network which does not run off the root of the domain, but is a path-based installation (not sub-domain) which uses the directory "/clubs/".
Example site URL may be; www.teamwebsites.co.uk/clubs/sitename
I am using the WPultimo plugin (an excellent one at that) which deals with domain mapping. However, when mapping the domain correctly, the only page which appears (with a standard .htaccess with the rewrite base set to "/clubs/") is the homepage - all other pages appear with a 500 Internal Server error. My host is Dreamhost.
Therefore I am trying to ensure both the mapped domain (if applicable) and standard WP subsite URL of each site correctly display, and so that all pages and posts on the mapped domain version do not display a 500 error. I have checked with the plugin author of wpultimo but he has exhausted all of his knowledge on this subject, as he is more of a design than server wizard.
The following is my .htaccess file as it currently stands. Note that the mapped domains work absolutely fine but the standard WP subsite URLs do not - examples being www.teamwebsites.co.uk/clubs/prdc, where the actual site does not even display due to the htaccess....
==> https://pastebin.com/raw/wYzEJ9kF <==
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteCond %{HTTP_HOST} =teamwebsites.co.uk
#RewriteRule ^([_0-9a-zA-Z-]+/)+(wp-(content|admin|includes).*) clubs/$2 [L]
# RewriteBase equivalent - for tree.mydom.us/twig/
RewriteCond %{HTTP_HOST} ===teamwebsites.co.uk
RewriteRule . - [E=REWRITEBASE:/clubs/]
RewriteCond %{HTTP_HOST} !=teamwebsites.co.uk
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ %{ENV:REWRITEBASE}$1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) %{ENV:REWRITEBASE}$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ %{ENV:REWRITEBASE}$2 [L]
RewriteRule . %{ENV:REWRITEBASE}index.php [L]
</IfModule>
# END WordPress
NOTE: I must still have the /clubs/ used as the multisite directory.
I think the confusion from the server is where mapped domains do not include the "/clubs/" as a suffix between the mapped domain itself and what follows as the post/page URL.
Please, if anyone has the solution to this, I would greatly appreciate it. After 3/4 hours of staring and trying to - along with the plugin author - change the code of the .htaccess, it's becoming ever so tedious!!
I have two domain names pointing to the same server and being accepted by the nameservers. My host calls this a domain alias. An older WordPress blog, olddomain.com, hosted a blog while a newer domain, newdomain.com, now hosts a revamped blog AND a portfolio site.
My client wants to capture his old blog traffic and allow those to pass through. That all works fine already because of the domain alias. In other words, without me doing anything to the .htaccess file, this internal redirect already happens:
http://olddomain.com/year/month/day/post-slug/ already redirects to:
http://newdomain.com/year/month/day/post-slug/
The problem is that we also need to redirect the olddomain.com homepage traffic to the new landing page of the blog. The old site's homepage was the blog, but the new site's homepage is the personal portfolio. Therefore, what I need htaccess to do is:
Retain the current domain name pass through as noted above, and made possible by the name servers and my hosts domain alias settings
Take any traffic that was intended for the old homepage and redirect to the new blog landing page, which looks like this:
olddomain.com(nothing else here) needs to redirect to newdomain.com/blog/(nothing else here)
The problem that I am having is that any solution that I put in place to do the above redirect messes with the natural redirection that is happening for the blog posts themselves. I can't quite get it to the point where I can have both at the same time. The htaccess also needs to retain the standard WordPress chunk that rewrites for the index.php file.
This is what I have currently, which rewrites olddomain.com to newdomain.com/blog/, but sends all other old traffic to specific blog posts back to the homepage instead of allowing the internal domain alias redirect to happen.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} (www.)?olddomain.com [NC]
RewriteRule ^(.*)$ http://newdomain.com/blog/ [R=302,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Thanks.
You can replace your existing code with these rules:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# redirect only landing page to new site's /blog/ URI
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+[?\s]
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^/?$ http://newdomain.com/blog/ [R=307,NE,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Test it from a new browser or after clearing your browser cache.
I have a website, https://www.example.com and subdomain, https://sub.example.com.
My problem is that whenever I try to visit https://sub.example.com I am redirected to https://www.example.com. But, when I visit http://sub.example.com, I am not redirected.
I have a wildcard SSL cert which should allow me to visit my subdomain with https://. Both sites run WordPress and are hosted with Bluehost. I have tried many solutions as well as contacting Bluehost customer support twice to no avail. I would like to be able to visit both my main domain and subdomain with SSL active.
I have edited the .htaccess file according to the following solutions found here: htaccess redirect domain to https, subdomain to http and www to non-www
# for main domain
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]
# for sub domain
RewriteCond %{HTTP_HOST} ^(www\.)?sub\.example\.com$ [NC]
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ http://sub.example.com%{REQUEST_URI} [R=301,L,NE]
https://my.bluehost.com/hosting/help/766
# Custom subdomain .htaccess SSL + WordPress
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.maindomain.com$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteRule ^(.*)$ /subfolder/$1
RewriteCond %{HTTP_HOST} ^subdomain.maindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
# End custom subdomain .htaccess
# Custom maindomain .htaccess WordPress
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?maindomain.com$
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTP_HOST} ^(www.)?maindomain.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# End custom maindomain .htaccess
http://www.wpbeginner.com/wp-tutorials/how-to-add-ssl-and-https-in-wordpress/
I have also tried fresh WordPress installs of both the main domain and subdomain with no luck. I'm not sure what else to try. Any help and suggestions would be much appreciated.
Several things to try:
First, when you're making changes, use a tool like Webconfs HTTP Header Checker. This way, if your web browser has redirects cached and you make a change that fixes the redirects, the Header Checker won't be fooled. Your web browser, on the other hand, will keep redirecting even after things are fixed, until you clear the cache. Alternatively, you can try a Chrome Incognito window.
Instead of using just the one .htaccess file, use one for each site. Assuming example.com is your primary domain, you can set rules for the "root" WP site in the root folder, and you'll set rules for the "subdomain" WP site in the folder where that separate WP install sits - /subdomain.com/.htaccess.
Make sure your "root" WP site URL and home URL are both set to the https version. You can do this in a couple of places: in wp-admin of the "root" WP site, go to Settings > General. The "WordPress Address (URL)" and "Site Address (URL)" both need the https. If they are set to http, it will log you out when you click save. Alternatively, you can do this in phpMyAdmin - in the wp_options table, look for the 'siteurl' and 'home' options and make sure they're https rather than http.
It sounds like your "root" WP was installed when the site was insecure, running on http. Sometimes it takes more than just updating the site URL and home URL. Try using WP Migrate DB which will do a search-and-replace to convert all instances of your http URLs to https URLs.
Once all that is done, if the "root" site still redirects to the non-secure version, you can install a plugin such as WordPress Force HTTPS.
I'm trying to make a website where all users are redirected to a specific part in the domain so that they can see a "comming soon" page. While some ip addresses can still access the normal website so that they can see how it is going to look.
What I'm trying to do: create a wordpress website in the root of public_html, create a soon directory in public_html and redirect all users except a few ip's to http://www.domain.com/soon/index.html
My .htaccess looks as followed:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^1.2.3.4
RewriteRule (.*) http://www.domain.com/soon/index.html [R=302,L]
However whenever I go to the website to test it out it tells me:
ERR_TOO_MANY_REDIRECTS
Is there something I'm doing wrong in my .htaccess?
Try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$
RewriteRule .? /soon/index.html [L]
Use this rule as your very first rule in your .htaccess:
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^(1\.2\.3\.4|11\.22\.33\.44)$
RewriteCond %{REQUEST_URI} !\.(?:jpe?g|gif|bmp|png|tiff|css|js)$
RewriteRule !^soon/index\.html$ http://www.domain.com/soon/index.html [R=302,L,NC]
Variable REMOTE_ADDR matches client's IP in a web request.
RewriteCond %{REQUEST_FILENAME} !-f is needed to avoid redirecting for css/js/image files and /soon/index.html file.