Images on my server redirecing to Google? - html

So I woke up this morning to my Wordpress websites all having their htaccess file modified (redirecting to spam). I replaced them with a backup file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
And then I refreshed my site and only 5% of the images from my /images/ folder are showing up.
All of my <img src paths are absolute. Even if I go to my image directory and click the image link directly, my browser thinks for a little bit and then goes to: https://www.google.com/?gws_rd=ssl
However, like I said, about 5% of the image links do actually work, and they're all the same filetype in the same directory.
It's very strange.
Edit: It seems to have been a server cache thing, things cleared up on their own after a few more minutes.

First, clear the cache of your browser, or try with a "Private Session" of Chrome / Firefox, maybe redirects are just still in your cache.
Second, check if there is another .htaccess in the images directory or in any parent directory up to the root of your site and check its content.
Third, check if non working images are presents on filesystem.
If there aren't anymore the redirect come from Wordpress and not from Apache.
Your CMS has been defaced, if you have a backup I think it's a good idea to restore it, or at least compare it file by file with your actual site (WinMerge can help you doing this).
I strongly suggest you to restore the backup and then check if your Wordpress installation is up-to-date and so every wordpress plugin you use.

Related

Redirecting multiple duplicate URLs to main URL using .htaccess

I developed a website and from SEO point of view, the homepage of a website is available under three or more different URLs which accordingly poses a risk of duplicate content, since the same content can be accessed via different URLs.
for eg.
my website is opening with below URL
https://www.insider.in/index.php
https://www.insider.in/
https://insider.in/
Exact URL which is needed be like
https://www.insider.in/
for achieving the same i am using an .htaccess file with code given below:
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.(php|html?)[#?]?
RewriteRule ^(([^/]+/)*)index\.(php|html?)$ https://insider.in/$1[R=301,L]
I tried to redirect all duplicate URLs to one URL using the above .htaccess file code but it is not working, also i enabled all the file permissions in FileZilla but again no success.
Any help or reference will be appreciated, thankyou!
note- website is hosted in cloud server using FileZilla
for Reference I am sharing the screenshots
Image of development folder for your reference
Image of .htaccess rule which i have used
You can use the rules below to fix duplicate content issues on your site :
RewriteEngine on
#Redirect non-www domain to www
RewriteCond %{HTTP_HOST} ^insider\.in$ [NC]
RewriteRule ^ https://www.insider.in%{REQUEST_URI} [NE,L,R=301]
#Redirect /index.php to /
RewriteCond %{REQUEST_URI} ^/index\.php$
RewriteRule ^ https://www.insider.in/ [L,R=301]
Remember to put theses rules at the top of your htaccess.

Pointing webserver to load .html page and not subdirectory index

So I have been searching for a few hours now and have not found the answer to my problem.
So I have a website that I was wanting to take the page extension off e.g. .html / .php etc.. and I had found that I could include the below code in the .htaccess file.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
I have now added that code and it works great for removing .html from my pages. However now I have come into a new problem. I have a page and directory both named 'guides' on the root of my public_html folder. Now when I enter the url 'www.mydomain.com/guides' the index of the guides directory is showing rather than the guides.html page that I am wanting to display.
I am wondering what would be the best way to get around this and make my server look for the webpage first rather than display the guides directory index.
I have been looking at RewriteRule's but it seems to be all wordpress content and does not work with my non wordpress website.
Any help would be appreciated, thanks.
The best solution is to change the name of the directory or the file to something different. RewriteRule can not rewrite a directory request to file as the directory request is first handled by mod-dir (directory module) .
If you do not want to change the name, then you can turn off DirectorySlash on your server using the following line in htaccess :
DirectorySlash off
https://httpd.apache.org/docs/2.4/mod/mod_dir.html#directoryslash

.htaccess file does not overwrite html and instead shows markup on page

I'm building a personal website, and I want my url links to look like domainname.com/example as opposed to domainname.com/example.html
I'm using fastcomet for my webhosting service. Under my public_html folder I have a .htaccess file. Here is the code for my .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
</IfModule>
My .htaccess file and all my html, css, js files are under home/username/public_html/ and I've removed the .html extensions from all my html files. After I applied these changes, I tried to get http://domainname.com/example and I saw the html markup as opposed to the rendered html such as:
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<all my code .... />
</html>
Any suggestions on what I should do? I am placing the .htaccess file in the wrong directory? I also tried with and without the Ifmodule tags on the .htaccess file.
Thanks!
Yes, indeed, you should keep the file extension .html so you can have your files properly handled and your .htaccess to work as intended. It seems that in the meantime, you have actually posted the ticket to our Tech Support Team. Though there has been a slight misunderstanding regarding your request, a senior member of our team successfully excluded the processing of HTML and HTM files from the NginX service and they are now passed directly to Apache for your domain. As a result, all of your url links now look like domainname.com/example as opposed to domainname.com/example.html. Should you have any further requests, do not hesitate to contact us back!
I've removed the .html extensions from all my html files
This is why you see page code.
Rename the files back and use the following rewrite rule:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
</IfModule>
FastComet Team here! Part of our shared hosting environment is utilizing NginX as a reverse proxy to the Apache web service. This means that static content, such as HTML files, is processed directly by NginX and not by Apache. This is why any rules that you apply to the .htaccess file of your website are not making any actual changes. The requests to HTML files will be processed directly by NginX and they will not be passed to Apache so the .htaccess rules will be ignored.
There is an easy way of resolving that. We can exclude the processing of HTML and HTM files for your domain or even your entire hosting account. This way, those requests will be processed by the Apache web server, instead of NginX. In this case, the .htaccess rules that you apply will be taken into consideration by the system and they will work without any issues. To achieve that, simply submit a ticket to our Technical Support team and we would be happy to assist.

Broken images on CodeIgniter website after uploading to server

I uploaded my CodeIgniter website to the server, but after uploading the website layout is not working properly. Some images work, but other images are not showing.
My .htaccess file:
RewriteEngine On
RewriteBase /beta
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
RewriteRule ^(.*)$ /beta/index.php?/$1 [L]
The base URL in config/config.php:
$config['base_url'] = 'https://www.lalcoresidency.com/beta/';
Here is my website link: https://www.lalcoresidency.com/beta/
There are several things to check that will help you trouble shoot.
The very first thing to do is to confirm that the image folders and files are actually on the server.
Try to figure out what the missing images have in common. Are they all in the same folder? If so, are permissions for that folder and its files set appropriately?
The owner of the folder(s)/file(s) will also need to be set appropriately. This will depend on the server. Many Apache based servers have the owner set to www-data.
Are any of the images loaded through css? For example, background-image: url("images/ui-icons_444444_256x240.png")? If so, confirm that the css file(s) are actually loading. Your browser's development tools will be invaluable for this. (Firefox uses Firebug and Chrome uses Web Developer)
I don't see any obvious problems with your .htaccess file.

Redirect non-existant site pages via .htaccess

I have a problem right now with visitors browsing to pages that used to exist on my server but no longer. This is due to my initially poor decision to use a subdirectory instead of a subdomain. Because of this, people posted direct links to the pages themselve instead of the directory to various message boards. So when people Google and find links to my site, they click what the people have linked and it directs them to a "Not Found" page.
To better explain, here is my best attempt at giving an example.
The main URL people were using to visit my site was hxxp://example.com/subsite/. Within that /subsite/ directory there were files such as welcome.html, about.html, contact.html. So what happened is that when people started spreading my website links around, they would spread a link such as hxxp://example.com/subsite/welcome.html instead of just hxxp://example.com/subsite/. As of right now, the subsite directory only has (mainly) an index.html file.
What I am trying to accomplish is that whenever someone tries to navigate to any webpage within that subdirectory that doesn't exist, it redirects them to the index.html file. I'd like to accomplish this via the .htaccess file.
I attempted to do this myself by using the below code, but apparently I'm too new to how the .htaccess and apache modules work and the below code causes a constant redirect loop.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ hxxp://example.com/subsite/ [L,QSA]
</IfModule>
If anyone has any input, or needs me to clarify any information just let me know. Any help would be greatly appreciated. Thank you!
You can use:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(subsite)/.+$ /$1/ [L,NC,R=301]