How can I force .htaccess to ignore a folder? - .htaccess

I was using the search function, but none of the solutions seem to work for me. I have the following .htaccess file
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(api) - [L]
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?action=$1 [L,QSA]
ErrorDocument 404 /tsi/index.php
ErrorDocument 403 /tsi/index.php
<FilesMatch ".*\.(php|tpl)$">
Order Allow,Deny
Deny from all
</FilesMatch>
<Files "index.php">
Allow from all
</Files>
<FilesMatch "hashgenerator\.(php)$">
Satisfy Any
Allow from all
</FilesMatch>
<FilesMatch "xmlgenerator\.(php)$">
Satisfy Any
Allow from all
</FilesMatch>
<FilesMatch "api\.(php)$">
Satisfy Any
Allow from all
</FilesMatch>
I have a folder named "api" which I want to be ignored by .htaccess.

Related

Htaccess contents keep getting replaced on shared hosting

The content in my shared hosting htaccess file keeps getting replaced with this:
<FilesMatch ".(py|exe|php)$">
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch "^(about.php|radio.php|index.php|content.php|lock360.php|admin.php|wp-login.php)$">
Order allow,deny
Allow from all
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I've tried location the script causing this but could not find it. I asked my hosting service and they claim it not caused by them.
Please do anyone have idea to what's causing this

Mask URLs with .htaccess without breaking the structure

is it possible to mask the url without breaking the structure?
I use LARAVEL
For example:
URL original:
https://site.test/public/store-owner/dashboard
URL masked
https://site.test/public/vendedor/panel
However, all the previous requests are not lost with the original url and the url in the address bar stays with the masked url
My .htaccess file in proyect
I have this code but the url changes in the address bar to the original one.
What I need is that the url mask does not change
RewriteEngine on
RewriteRule ^public/vendedor/panel/?$ public/store-owner/dashboard? [NC]
------------------------
FileETag none
<IfModule mod_rewrite.c>
RewriteEngine On
#Redirect to non-www with https
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
# BEGIN Caching
<ifModule mod_headers.c>
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|ttf|otf|woff|woff2|eot|svg)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch "\\.(css)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
#<filesMatch "\\.(js)$">
#Header set Cache-Control "max-age=2592000, private"
#</filesMatch>
<filesMatch "\\.(xml|txt)$">
Header set Cache-Control "max-age=2592000, public, must-revalidate"
</filesMatch>
<filesMatch "\\.(html|html|php)$">
Header set Cache-Control "no-store"
</filesMatch>
</ifModule>
# END Caching
<FilesMatch ".(eot|otf|ttf|woff|woff2)">
Header always set Access-Control-Allow-Origin "*"
</FilesMatch>
<Files .json>
Header unset Cache-Control
</Files>
<Files .env>
order allow,deny
Deny from all
</Files>
RewriteEngine On
RewriteBase /
#force https and non-www
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
# profile redirection
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(.*)\.site.test [NC]
RewriteRule (.*) https://site.test/stores/%1/$1 [L]
Not Sure this works. But just give a try
RewriteEngine on
RewriteRule ^vendedor/panel/?$ public/store-owner/dashboard? [NC]

how can I allow robot.txt in my .htaccess file

I am trying to make robots.txt and favicon.ico accessible through http. They are both in my app's root directory. I want them to be able to go to mydomain.com/robots.txt and my robots.txt file and same with favicon.ico. I have looked at other examples on the internet and stack overflow but I can't seem to get it working for my specific .htaccess file.
RewriteEngine on
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule ^folder1/(.+)?$ folder1/$1 [L]
RewriteRule ^folder2/(.+)?$ folder2/$1 [L]
RewriteRule ^folder3/(.+)?$ folder3/$1 [L]
RewriteRule ^folder4/(.+)?$ folder4/$1 [L]
RewriteRule ^robots.txt [L]
RewriteRule ^favicon.ico [L]
RewriteBase /
RewriteRule !\.(gif|jpg|jpeg|png|css|js|php|htaccess|xml|htm|html|swf|pdf)$ index.php
<ifModule mod_headers.c>
# Expires after 1 month
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2592000"
</filesMatch>
# Expires after 1 day
<filesMatch ".(jpg|jpeg|gif|png|x-icon)$">
Header set Cache-Control "max-age=31536000"
</filesMatch>
</ifModule>
This worked:
RewriteEngine on
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule ^folder1/(.+)?$ folder1/$1 [L]
RewriteRule ^folder2/(.+)?$ folder2/$1 [L]
RewriteRule ^folder3/(.+)?$ folder3/$1 [L]
RewriteRule ^folder4/(.+)?$ folder4/$1 [L]
RewriteRule "^robots.txt$" "robots.txt" [L]
RewriteRule "^favicon.ico$" "favicon.ico" [L]
RewriteBase /
RewriteRule !\.(gif|jpg|jpeg|png|css|js|php|htaccess|xml|htm|html|swf|pdf)$ index.php
<ifModule mod_headers.c>
# Expires after 1 month
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2592000"
</filesMatch>
# Expires after 1 day
<filesMatch ".(jpg|jpeg|gif|png|x-icon)$">
Header set Cache-Control "max-age=31536000"
</filesMatch>
</ifModule>

Force SSL with .htaccess

I know there are lots of similar (read: identical) questions, but I've tried everything - doesn't work.
This is my code:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [L,NE,R=301]
RewriteRule ^admin/(.*)$ backend/web/$1 [L]
RewriteRule ^developers/(.*)$ api/web/$1 [L]
RewriteRule ^(.*)$ frontend/web/$1 [L]
</IfModule>
# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
Order allow,deny
Deny from all
</Files>
# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]
Everything I get is only a redirect loop.
I'm using Heroku.
Thanks.

You don't have permission to access /magento/

I've put on the host in magento in sub-folder /magento/ and when I try to open http://example.com/magento/ I got this error
Forbidden
You don't have permission to access /magento on this server.
I know is something from the .htaccess file because if I remove/rename it I can open it but I don't know what exactly can do this in .htaccess. Is someone had this problem before and can give some info how to fix it?
I'll post lines that are not commented in default .htaccess
DirectoryIndex index.php
<IfModule mod_php5.c>
php_flag magic_quotes_gpc off
php_flag session.auto_start off
php_flag suhosin.session.cryptua off
php_flag zend.ze1_compatibility_mode Off
</IfModule>
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
<IfModule mod_ssl.c>
SSLOptions StdEnvVars
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^api/rest api.php?type=rest [QSA,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</IfModule>
Order allow,deny
Allow from all
<Files RELEASE_NOTES.txt>
order allow,deny
deny from all
</Files>
This looks like file permission issue. Check if your web server has the rights to read and execute on that magento folder.

Resources