Hi what does this code do, I have a seo company doing some work on my site, and just noticed this being on my server. thanks
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^mydomain.com [nc]
rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]
If users try to access http://mydomain.com/ they will be redirected to http://www.mydomain.com/.
This is useful to avoid Duplicate Content, which search engines don't like. So it's basic SEO.
Duplicate Content means that the Content of a website is accessible at more than one URL, in your case http://mydomain.com/ and http://www.mydomain.com/. The RewriteRule kills the URL without www.
Related
my domain breaktagdigital.com needs to be redirected to https://breaktagdigital.com.au I already have this setup in my rewrite rules which does not seem to be redirecting the URL or any other pages, which it is also not allowing me to do within wordpress, force secure is on within cloudflare and I just turned it off in Ithemes:
RewriteCond %{HTTP_HOST} ^www.breaktagdigital.com.au [NC]
RewriteCond %{HTTP_HOST} ^breaktagdigital.com [NC]
RewriteRule ^(.*)$ https://breaktagdigital.com.au/$1 [L,R=301,NC]
if I add anything to this to try redirect breaktagdigital.com any further it breaks .com.au help please?
Should I be putting another if module in between wordpress and ithemes??
Based on your shown samples, could you please try following. This will redirect from www/non-www yoursite.com TO yoursite.com.au site. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(?:www\.)(breaktagdigital\.com) [NC]
RewriteRule ^ https://%1.au%{REQUEST_URI} [L,R=301,NE]
My company has moved our primary domain from architectsmarketing.com to archmarketing.org, and recreated many of the pages using the same WordPress page structure with a new WordPress theme.
However, some of the pages are rather complicated, and depend on the functionality of the old theme, so we'd prefer to leave these pages for now on the old site.
We're using .htaccess to do a 301 Redirect for the site, which works nicely:
RewriteEngine on
RewriteBase /
RewriteRule (.*) http://archmarketing.org/$1 [R=301,L]
Since we want to be able to access the back end, I added a condition:
RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-login|wp-content|wp-includes|dap) [NC]
To access site pages normally (without redirects) for comparison with the new site, I sometimes add a condition to exclude my specific IP address, which works perfectly:
RewriteCond %{REMOTE_HOST} !^73.222.196.53
The tricky part is when I try to keep SOME of the WordPress pages still going to the original site. For example, here is a page URL that I want to access on the old site:
http://architectsmarketing.com/petrie-method/optin-1/
I've tried using the following condition:
RewriteCond %{REQUEST_URI} !^/(petrie-method).*$
This does match the page and exclude it from the RewriteRule, but it doesn't allow the page URL to be resolved properly. Instead, that URL redirects to the root of the new site.
So to sum up, my current code (without the IP exclusion) that doesn't quite work is:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-login|wp-content|wp-includes|dap) [NC]
RewriteCond %{REQUEST_URI} !^/(petrie-method).*$
RewriteRule (.*) http://archmarketing.org/$1 [R=301,L]
NOTE: This all goes above the standard WordPress Rewrite block.
I would greatly appreciate any assistance. I have been researching .htaccess rules for hours, and tried dozens of code combinations without success.
I'm trying to ensure my site always runs on https://www.angelleye.com. So, both with https:// and the www. I've read some basic guides and they pretty much all show this, which is what I'm currently using.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
When I view my home page it seems to redirect me to https:// as expected, however, if I directly load other URLs it doesn't. For example, if I type this into my browser: http://angelleye.com/product-category/paypal-tools/ then it does add the www. for me, but it leaves me on http:// instead of moving me to https://.
Did I do something wrong with my htaccess rule? Any info on how I can get this working as expected would be greatly appreciated. Thanks!
EDIT: I'm using WordPress with the WP Rocket caching plugin, and I just noticed that it added a bunch of rules above my rules. Maybe there's a conflict..?? Here's a link to see the whole thing: http://pastebin.com/fJTmbk05
EDIT 2: It seems to be something about my WordPress config, but I can't figure out what it would be. If I try a URL outside my WP install it works fine. (ie. http://angelleye.com/temp/ball.gif)
EDIT 3: Well, now this URL is in my WP structure but it works fine (angelleye.com/category/blog/). So it seems that some URLs do work, but many do not..??
EDIT 4: I've completely removed my caching plugin, so my htaccess file now has nothing but my redirect rule. Still works fine outside the WP structure, but not within.
Your .htaccess file contains three sections for rewriting. The first is plugin-related, the second is WordPress-related, and the third is for your additions.
As your rules are in the third block, they won't be seen as the WordPress rule has already taken effect.
So, you need to move the rules you added to line 133 (above the first mod_rewrite definition).
The 'chain of command' or priority is now:
Force HTTPS and www.
WPRocket-associated rules
WordPress 'core' rules
Try below code to redirect http to https forcefully with parameters.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]
Do you have the AllowOverride set in the httpd.conf?
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?secure/(.*) https://%{SERVER_NAME}/secure/$1 [R,L]
# This rule will redirect all users who are using any part of /secure/ to the same location but using HTTPS.
You would replace secure with angelleye.
I have a client project that requires a specific domain name to be redirected to another directory, while the rest of the site is a standard WordPress installation.
My redirect appears to be written properly, and is placed at the very top of the htaccess file:
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^old_domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.old_domain\.com$ [OR]
RewriteRule ^/?$ "http\:\/\/www\.new_domain\.com\/directory\/" [R=301,L]
The problem is that it won't redirect http://old_domain.com/index.html
Instead, it sends the user to WP's 404 page.
What am I doing wrong?
UPDATE:
After receiving an otherwise helpful suggestion, I thought some additional context would be in order.
This is a real estate project. The main WP site (new_domain.com) is for condo sales, and they have a separate external site for condo rentals.
They have a third legacy domain (old_domain.com) that they want to redirect to a portal page (new_domain.com/directory), where the user can select buy or rent, and then proceed to the appropriate site.
So, we don't want all requests to be redirected, just any that use the legacy domain.
The following rule should work. It should redirect all requests from www.old_domain.com and http://old_domain.com to http://www.new_domain.com/directory
RewriteEngine On
RewriteRule ^(.*)$ http://www.new_domain.com/directory/$1 [R=302, L]
Change 302 to 301 when you are sure the redirect works
EDIT:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old_domian.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old_domain.com$
RewriteRule (.*)$ http://www.new_domain.com/directory/$1 [R=302,L]
You must have RewriteEngine On. You can consolidate the two www. and non-www. tests. Don't put an [OR] after the last RewriteCond.
RewriteCond %{HTTP_HOST} ^(www\.)?old_domain\.com$
Is new_domain.com an "add-on" to old_domain.com, so that both pass through the same .htaccess file, but with different domain names? Or are these physically separate systems, with their own .htaccess files? That is, what URLs are going to pass through this .htaccess file?
Your current code will redirect anything coming in on old_domain.com to /directory/<original URI+Query String> on new_domain.com, and tell search engines and users to update their entries and bookmarks. Is that what you want?
I have a website located here: https://www.virginiaseo.org
I use a Wordpress plugin, which forces all content to be over HTTPS. Without this plugin, I get the little yellow mixed content sign, which is less than desirable. This plugin forces every page including admin to be on HTTPS.
Here is the plugin page: http://wordpress.org/plugins/wordpress-https/
I also use .htaccess rules, and include one to force HTTPS. Here is the rule:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.virginiaseo.org/$1 [R=301,L]
</IfModule>
This all works great, except for a couple of resources I can't get over http which are needed by third party crawlers and applications. A prime example is: robots.txt
How can I make robots.txt accessible over http while not messing up everything else on the site.
Also, the HTTPS configuration with the plugin is less than prime, but it seems the only way to FORCE HTTPS on my entire site. I am concerned with duplicate content issues and such by having it available on http at the same time. I am open to any suggestions about my setup, and thanks in advance!
You can try a rule like this:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !/(robots\.txt|favicon.ico) [NC]
RewriteRule ^(.*)$ https://www.virginiaseo.org/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule ^(robots\.txt|favicon.ico)$ http://www.virginiaseo.org/$1 [R=301,L]