unable to add sitemap from AWS Amplify - .htaccess

I'm trying to submit a sitemap to Google that is on AWS Amplify. The sitemap is in XML format and in my site's root folder. When I submit the sitemap in the Google Search Console, I get a 403 forbidden error.
I have a .htaccess file in my site's root folder which may have something to do with the problem. I'm wary of making changes to the .htaccess and mess up the rules I've set up.
This is my htaccess file:
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
# deny access to .htaccess
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>
# prevent website directory listing
Options -Indexes
# Disable image hotlinking
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mattdailey.net [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ https://www.example.com/assets/images/hotlinking.png [R,L]
I'm not really sure if I need an .htaccess file on AWS Amplify. I couldn't find anything in the Amplify documentation mentioning .htaccess.
Here is my sitemap XML file:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com</loc>
<lastmod>2021-02-10</lastmod>
<changefreq>monthly</changefreq>
</url>
</urlset>
How do I get rid of the 403 forbidden error?
Do I modify my .htaccess file or is there a setting in AWS I need to change? I recently moved my site to Amplify and still new to it.

Related

Loading content from subpage while keeping entered url via htaccess doesn't work and takes subpage url instead

I have two CMS which should sown on the same domain.
Depending how the url looks htaccess sends the quest to TYPO3 or Wordpress.
Without the ProxyPass/Reverse the htaccess loads the content but change the url to the cms url but I want to keep my entered URL.
When I upload the ProxyPass variables i get a 500 error.
But when i keep the the 500 error disapears.
What did I miss?
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?route-root.domain\.de$ [NC]
RewriteRule ^(.*)$ http://www.route-wp.domain.de/$1 [NC,P,L]
</IfModule>
<IfModule mod_proxy.c>
ProxyPass / http://www.route-wp.domain.de/
ProxyPassReverse / http://www.route-wp.domain.de/
</IfModule>
I guess, i did nothing wrong in particular.
My guess is that my host don't let me use this directives.
When I tried to create a logfile via ErrorLog I also get a 500.

Htaccess Font Face and Material Icons Css Not working after URL Rewrite

Hi I've got a wierd issue after a htaccess url rewrite... it works fine for the homepage but if i use the format subdomain.domain.com some fonts don't work, some do. The icons don't work it just shows a placeholder icon. It can't load the woff files etc. I think it may be the htaccess directoryindex disabled but i've put a special rule to allow the homepage to be displayed. How do I do the same for the \img\font\ folder which has the fonts. Also more importantly is disabling directoryindex best practice (i did this to avoid index.html being appended to the url's otherwise the rewrite subdomains doesn't work as it always encounters trailing index.html. Is there a way to set directoryindex to empty "" so that the second query works and I don't have to keep adding rules to allow specific folders?
DirectoryIndex disabled
#rewrite homepage to index.php to allow homepage as directoryindex is disabled
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^/?$ index.php [L]
#Rewrite subdomains
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_HOST} ^(^.*)\.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/index.php?sub=%1 [P,NC,QSA,L]
Thanks!
P.S The earth really is flat.
I'm getting CORS errors in the console but it's the files are on the same server and domain.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://example.com/img/icon/fonts/materialdesignicons-webfont.woff2?v=2.0.46. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). (unknown)
downloadable font: download failed (font-family: "Material Design Icons" style:normal weight:normal stretch:normal src index:1): bad URI or cross-site access not allowed source: http://example.com/img/icon/fonts/materialdesignicons-webfont.woff2?v=2.0.46
Adding this to htaccess fixed everything
<IfModule mod_headers.c>
#allow corrs access from subdomains
SetEnvIf Origin ^(https?://(?:.+\.)?example\.com(?::\d{1,5})?)$ CORS_ALLOW_ORIGIN=$1
Header append Access-Control-Allow-Origin %{CORS_ALLOW_ORIGIN}e env=CORS_ALLOW_ORIGIN
Header merge Vary "Origin"
</IfModule>

Use .htaccess to block all domains to access images folder except myown domain

i want to use .htacess to block all domains to access my images folder.
this folder is only accessible by own domain only.
I think what you are looking for is some sort of hotlink protection in which case this in your .htaccess file should work:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
Change yourdomain.com to whatever your domain is. Change the RewriteRule to include any file extensions you wish to block and then place the entire thing in a .htaccess file in the directory you wish to protect.
As described in this page of Apache docs, you can accomplish it with the following directives, replacing example\.com with your domain name (please remember to escape any dot characters from . to \.:
SetEnvIf Referer example\.com localreferer
<FilesMatch \.(jpe?g|png|gif)$>
Order deny,allow
Deny from all
Allow from env=localreferer
</FilesMatch>

Deny access to favicon

I currently have 2 domains using the same httpdocs folder, what i need to do is to deny the access to the favicon when the request comes from one of my domains or simply redirect it to another favicon file.
I've been trying to solve this by editing the .htaccess file but i can't figure out how to make the RewriteRule to work.
Thank you very much
To deny access to the favicon.ico completely you can use a <Location> directive in your .htaccess file:
<Location /favicon.ico>
Order deny,allow
Deny from all
</Location>
If you wanted to redirect instead, you might do it this way:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^host1.domain.com$
RewriteRule ^favicon.ico /host1-favicon.ico
RewriteCond %{HTTP_HOST} ^host2.domain.com$
RewriteRule ^favicon.ico /host2-favicon.ico

.htaccess help - not working

I want to rewrite all .php into .html,,, so i created a .htaccess file and added
AddHandler application/x-httpd-php .php .html .htm
but when it seems not working...
here i uploaded all files - http://www.fellowindian.com/ca/index.php & http://www.fellowindian.com/ca/page1.php
1: Do you have mod_mime installed on Apache.
2: Are you sure that .htaccess is executing.
Simple test would be to see if it can rewrite your urls to add / remove www from it.
Example:
Options +FollowSymLinks RewriteEngine
On RewriteBase / RewriteCond
%{HTTP_HOST} !^www\.mycee\.com$ [NC]
RewriteRule ^(.*)$
http://www.mycee.com/$1 [R=301,L]
3: Which user is the owner of the .htaccess file and what is its attributes?
4: Check that the AllowOverride directive is set in your apache config and not set to None.
Test by putting invalid directives in the .htaccess file and reloading the page.
If the apache error log doesn't show any errors, it's not executing.
5: If you're on shared hosting, check with your host if they have AllowOverride enabled or not.
Personally, I think the best place to put the AddType directive would be in apache's httpd.conf as .htaccess puts a performance hit on your server, but in the case of shared hosting, .htaccess is usually the only option available.
If you're trying to redirect something.php to something.html, you could do
RewriteEngine On
RewriteCond %{REQUEST_URI} .php$
RewriteRule (.*?).php $1.html

Resources