Web page is refressing again and again - html

I have google cloud storage hosting. I have made changes to google search console to where I have verified my domain name with www and without www so that my website will be available to access trough both. I have also tried to put redirect code in .htaccess file in cloud storage. After this changes when I am reloading my website it is automatically refreshing it self again and again?
Code written in .htaccess file is:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^turtlelabs\.co.in\
RewriteRule (.*) http://www.turtlelabs.co.in\ [R=301,L]

maybe this will help:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^turtlelabs.co.in\
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}\$1 [R=301,L]

Related

Redirect from one website to another and keep directory

The blog section of a website moved from a subdomain to a directory of the main domain. I need to redirect all users visiting blog.site.com to site.com/blog/ and the directory someone enters should be kept when forwarding, e.g. blog.site.com/post/welcome should point to site.com/blog/post/welcome
I treid adding this to my .htaccess file which I placed in the subdomain's directory via FTP:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog.herderzeitung.de$ [OR]
RewriteCond %{HTTP_HOST} ^www.blog.herderzeitung.de$
RewriteRule (.*)$ https://herderzeitung.de/blog/$1 [R=301,L]
However, this doesn't seem to be working. I was also wondering, what the most SEO friendly way is to achieve this (the site permanently moved to another domain).
Thanks in advance!
Try
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.herderzeitung\.de$ [OR]
RewriteCond %{HTTP_HOST} ^www\.blog\.herderzeitung\.de$
RewriteRule ^/?(.*)$ https://herderzeitung.de/blog/$1 [R=302,L]
I've escaped the dots, and anchored&normalized the pattern. Also switched it to temporary redirects (302); once you know it works, then change it to 301 again for SEO reasons.
And yes, as far as i know 301s are the best method for retaining your search rankings and the like.
This seems to work:
RewriteEngine On
RewriteCond %{REQUEST_URI} (.*)
RewriteRule ^(.*)$ https://herderzeitung.de/blog/$1 [L,R=301]
Thank you everyone!

Image url being treated as a page request in yii2

I am working on a project which is developed in Yii2. Today I came across a weird and funny issue of image url being treated as a page request.
When I try accessing image with url as https://www.websitename.com/images/image1.jpg, it shows me the image. And when I try accessing image with url as https://www.websitename.com/images/image1-lockdown.jpg then it shows 404 Error. On checking I found that internally the request was changed to "/site/images/image1.jpg". As we all know to access images no controller call is made.
Same issue was generated on local machine (Ubuntu 16.04). Just added "lockdown" into the name of image url.
I am using Yii2 Advanced Template. OS: For production CentOS and for development Ubuntu 16.04.
Note: I couldn't verify if the same issue exists for windows or not.
Kindly Help!
Edited: .htacess (root folder on production)
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule admin(.+)?$ /backend/web/$1 [L,PT]
RewriteRule gamer/(.+)?$ /gamer/web/$1 [L,PT]
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ /frontend/web/$1 [L]
</IfModule>
.htaccess (frontend/web on production)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

How to redirect all html files in a domain to a specific webpage?

I have 2 bluehost accounts. One belongs to a former employee and the other is our companies new one. We have several domains in the old account, like chinafabrix.com and we want all domains to redirect to our new website vitasino.com. The thing is that we dont just want chinafabrix.com to redirect but also chinafabrix.com/index.html chinafabrix.com/whatever.html chinafabrix.com/blahah.html etc etc to redirect to vitasino.com (not vitasino.com/x.html but only vitasino.com)
Is there any way of doing this without writing a separate redirect in all the html files in the domain?
RewriteEngine on
RewriteRule ^(.*)$ http://www.vitasino.com/$1 [R=301,L]
or
RewriteEngine On
RewriteRule ^(.*)$ http://vitasino.com/ [R=301]
In the site root .htaccess of your old site you can place this single catch-all rule:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?chinafabrix\.com$ [NC]
RewriteRule ^(.+\.html)?$ http://vitasino.com/? [L,NC,R=301]

Need Help in my website IP Canonicalization .htaccess

i have searched the whole internet to find solution my website is www.hrxlevels.tk and ip address associated with website is this 31.170.163.33 and want the .htaccess for ip to redirect to domain
# Do not remove this line, otherwise mod_rewrite rules will stop working
RewriteEngine On
RewriteCond %{HTTP_HOST} ^hrxlevels.tk [NC]
RewriteRule ^(.*)$ http://www.hrxlevels.tk/$1 [L,R=301]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^31\.170\.163\.33
RewriteRule ^(.*)$ http://www.hrxlevels.tk/$1 [L,R=301
RewriteBase /
and this code is not working for ip canonicalization but works great for url cononicalization please help please!
please use this detail and please write the .htaccess file for my website.
My webhost is 000webhost.com

What is the proper .htaccess for blocking another website assigned to my dedicated IP

Here is my scenario: I have a website, that I own, and another website, which someone I don't know owns, is also assigned to that same IP address. When I view their website it is basically displaying all of the content from my website. This URL is #1 in certain keywords I'm using any my website is several pages deep in google. I can also log into the administrator portion of the website through the other URL that I don't own, which worries me from a liability stand point. I contacted my hosting provider and after about an hour and nothing to show for it here I am.
What I want to do is block the other website in .htaccess OR completely redirect all pages from that URL to my URL...
What is the best redirect method or code in this instance?
What I currently have still in my .htaccess allows the index page to be loaded on the remote website but all of the images and css loaded by that index page respond with a 403 forbidden. Problem with that is it is still loading my index page's meta description, keywords, html, and styles which is messing with my search engine optimization attempts.
I want the index page to not even load resulting in a forbidden error or a complete redirect including the base index page.
I also want to redirect any traffic that doesn't include the www before my domain to the www version and not result in a redirection loop.
Any help is greatly appreciated.
RewriteCond %{HTTP_REFERER} otherdomain\.com [NC]
RewriteRule .* - [F]
RewriteCond %{HTTP_HOST} ^otherdomain\.com [NC]
RewriteCond %{HTTP_HOST} ^mydomain\.com [NC]
RewriteRule ^(.*)$ http://www\.mydomain\.com [R=301,L]
Use this code:
# block other domain
RewriteCond %{HTTP_HOST} ^(www\.)?otherdomain\.com$ [NC]
RewriteRule ^ - [F]
# put www before host name
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]