URL redirect issue - .htaccess

I have a problem with redirecting single webpages within my website.
I am trying to redirect https://job-center.hu/munkaero_kozvetites/ to https://job-center.hu/munkaero-kozvetites/ and I am using the following htaccess file to do this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q=/$1 [QSA]
</IfModule>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.allasajanlat.job-center.hu [NC]
RewriteRule ^(.*)$ https://allasajanlat.job-center.hu/$1 [L,R=301]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.job-center.hu [NC]
RewriteRule ^(.*)$ https://job-center.hu/$1 [L,R=301]
Options -Indexes
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
Redirect 301 /munkaero_kozvetites/ https://job-center.hu/munkaero-kozvetites/
#SetEnv skip-cache
The result is a strange URL and I am not sure if this is OK.
Would this be considered as duplicate content by Google or this is OK as it is.
Thanks for your help in advance.

For your question about google, Redirect 301 is a permanently redirect, which means google will consider both sites the same content.

Related

.htaccess 301 Redirect Except Main Page for .html

I'm trying to redirect all URLs in www.oldexample.com/index.html to www.newexample.com/index.html except the homepage (www.oldexample.com/index.html).
I have tried this:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.oldexample\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/?$ [NC]
RewriteRule ^(.*)$ http://www.newexample.com/$1 [R=301,L]
but it didn't work. It is redirecting all pages.
How can I make it work?
Please try with below,
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html
RewriteRule ^(.*)$ http://www.newexample.com/$1 [R=301,L]

301 redirect not working in .htaccess

I have two domains, autodromodifranciacorta.it and franciacortacircuit.com both pointing to the same website hosted on this IP address: 94.23.64.40.
Now i want all the content to be under one single domain, so i decided to 301 redirect all the traffic from franciacortacircuit.com to autodromodifranciacorta.it
Here is my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Redirect Entire Site to New Domain
RewriteCond %{HTTP_HOST} ^franciacortacircuit\.com$ [NC]
RewriteCond %{HTTP_HOST} ^www\.autodromodifranciacorta\.it$ [NC]
RewriteRule ^(.*)$ http://autodromodifranciacorta.it/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
The redirect is not working and i have no clue why, because the syntax looks correct to me.
The .htaccess file is processed, because if i put a typo in it, i get server error.
Wha'ts wrong with it?
Your second http_host condition is wrong and it never matches if the current host is franciacortacircuit.com, You need to use an OR condition to match against 2 diffrent hosts.
#Redirect Entire Site to New Domain
RewriteCond %{HTTP_HOST} ^franciacortacircuit\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.autodromodifranciacorta\.it$ [NC]
RewriteRule ^(.*)$ http://autodromodifranciacorta.it/$1 [R=301,L]

301 redirect for .ca domain to .com domain

I'm trying to do a .ca to .com domain 301 redirect however no matter what I do it doesn't work. I've not actually done this before so I've serached about it but the code I have in doesn't work? As my .ca domain just goes to a "not found" page. Shouldn't be be redirecting to my .com domain
Here is the code I have in my .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.ca [NC,OR]
RewriteCond %{HTTP_HOST} ^example.ca [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301,NC]
I have a bunch of rules form W3TC and this snippet which I'm assuming has to do with a landing page plugin we have on the site:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{QUERY_STRING} !lp-variation-id
RewriteRule ^go/([^/]*)/([0-9]+)/ /go/$1?lp-variation-id=$2 [QSA,L]
RewriteCond %{QUERY_STRING} !lp-variation-id
RewriteRule ^go/([^/]*)? /wp-content/plugins/landing-pages/modules/module.redirect-ab-testing.php?permalink_name=$1 [QSA,L]
RewriteRule ^landing-page=([^/]*)? /wp-content/plugins/landing-pages/modules/module.redirect-ab-testing.php?permalink_name=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Advice is great! Thanks!

htaccess redirect http to https for subdirectory

I use this redirect because my website is inside a subfolder (www.domain.com/subfolder/)
So if someone enters the website, it will load like this: http://domain.com
What do I need to add or change in .htaccess so that it redirects automatically to https://domain.com, counting that the website is at domain.com/subfolder
I have tried various redirect codes, but no success. If someone is kind to point me in the right direction or give me a hint.
Thanks for the help.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ subfolder/index.html [L]
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^ https://{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
RewriteRule !^subfolder/ subfolder%{REQUEST_URI} [L,NC]

301 redirect with htaccess & textpattern

Trying to set up a 301 redirect for a change in domain. I'm using Textpattern which already has a mod rewrite. When adding the redirect I'm prompted with a error page on the site, stating that the page has resulted in too many redirects!
This is the htaccess file in use...
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /relative/web/path/
RewriteRule (.*) http://www.domain.com/$1 [R=301,L] #(this has been added to the default textpattern htaccess file)
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php
RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
Many thanks for any advise you can give.
From what domain you try to redirect? May be you have set cycling - trying to redirect from site.com to site.com?
Add this after RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?!www.yournewdomain.com$).*$
RewriteRule (.*) http://www.yournewdomain.com/$1 [R=301,L]

Resources