301 Redirect Full URL - .htaccess

How do I create a redirect so that http://fullurl/store redirects to
https://fullurl/store
Do I do this in htaccess or robots?
Thanks for your help

robots.txt is used only for telling search engine bots and other crawlers how to deal with your URL structure, it has nothing to do with redirecting the user.
To force HTTPS on a site, add the following to the .htaccess file in the web root of fullurl (or inside the root of store to redirect only that directory to HTTPS):
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Related

.htaccess Rewrite code to 301 redirect my URL path to fix canonical issues

I discovered recently that a Hostgator tech inserted rewrite code in my .htaccess file which 302 redirected all of my pages to https://example.com even though I wasn't using that URL path for my sitemap or internal links. Now I have a mix of URL paths indexed by Google and lots of duplicate pages.
Trying to clean it up and use one URL path -> https://example.com
This is the code they inserted:
RewriteCond %{HTTP_HOST} example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
RewriteEngine on
RewriteOptions inherit
Can I simply change the [R,L] to [R=301,L] so that now everything will be a permanent redirect? I will also update all internal links and sitemap to use this URL path.

TYPO3 HTACCESS | changing HTTPS to HTTP in url redirects me to the root page

When I change my url from https://www.example.com/company/ to http://www.example.com/company/
I get redirected to the root page instead of it changing HTTP to HTTPS. What am I missing?
Here is my HTACCESS file, I am using a TYPO3 CMS 7.6.19
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
The default .htaccess file for TYPO3 does some rewriting of its own. If you place this below at the bottom of that file, it will first execute the default rules. This will mess up your redirect. You should add these redirect rules above the default TYPO3 rewrite rules, so just below the existing RewriteEngine On.

Htaccess redirect from subdirectory in one domain to another domain subdirectory

I am trying to create a permanent htaccess redirect (301) from all files in one directory in one domain, to another domain sub-directory as follows:
Redirect all files in the following directory:
from: www.xxx.com/apps/forms/reg.html
to: www.yyy.com/apps/forms/reg.html
if someone entered the first url it should redirect to the second url
Please help on this to fix my redirection issue
Try this:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} domain1.extension$ [NC]
RewriteRule ^(.*)$ http://domain2.extension$1 [L,R=301]

Why isn't my .htaccess 301 redirect working?

I'm trying to redirect this URL to a different subdomain but am getting a 404.
Need to redirect:
www.dustystrings.com/instrumentbuilding / XYZ
To here:
manufacturing.dustystrings.com/instrumentbuilding / XYZ
I have www.dustystrings.com on one server, and manufacturing.dustystrings.com on another server (necessity).
Basically, I want to redirect all www.dustystrings.com/instrumentbuilding/ queries to manufacturing.dustystrings.com/instrumentbuilding/
What's the right .htacess 301 code to do this? (Apache server)
This should work:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.dustystrings.com[nc]
RewriteRule ^.*/instrumentbuilding/(.*)$ http://manufacturing.dustystrings.com/instrumentbuilding/$1 [r=301,nc]
Redirect to www using htaccess redirect
Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Please REPLACE domain.com and www.newdomain.com with your actual domain name.
Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.

URL-based redirect with Htaccess

I have several domain aliases pointing to the same website like:
domain1.de/en/
domain1.de/de/
domain2.ch/de/
domain2.ch/en/
When someone opens a specific language-based sub-directory on a URL, I would like to redirect them to the start page, e.g. for domain1.de users shouldn't be able to access the sub-directory /en/ but be redirected to the start page. For the domain2.ch users should only have access to the directory /en/ and not /de/. How can I set this up with Htaccess?
This might be a helpful link to you;
htaccess redirect
for a 301 redirect entire directory it generated the following code:
//301 Redirect Entire Directory
RedirectMatch 301 domain2.ch/de/(.*) domain2.ch/en//$1
RedirectMatch 301 domain1.de/de/(.*) domain1.de/en//$1
Give this a try:
RewriteCond %{HTTP_HOST} ^de\.domain\.de$ [NC]
RewriteCond %{REQUEST_URI} ^(.*)/en/(.*)$ [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/targetpage.php [R=301,L]

Resources