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>
Related
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]
New to htaccess... All files exist despite 404. There are actual 50+ images in this one folder but 3 images are getting a slash added to the end.
not working:
http://shawnrieger.dev/img/photography/small/20100402153906_s.jpg/
http://shawnrieger.dev/img/photography/small/20140404123054_s.jpg/
http://shawnrieger.dev/img/photography/small/20130330110114_s.jpg/
an example of working:
http://shawnrieger.dev/img/photography/small/20160913190428_s.jpg
http://shawnrieger.dev/img/photography/small/20120613091849_s.jpg
http://shawnrieger.dev/img/photography/small/20120713102800_s.jpg
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^privacy-policy/$ /parts/pages/privacy-policy.php
RewriteRule ^project/([^/]+)/$ /parts/pages/project.php?id=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
<IfModule mod_headers.c>
# WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
</IfModule>
You must avoid adding trailing slash for real files and also reorder your rules.
Have it like this:
<IfModule mod_headers.c>
# WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301,NE]
RewriteRule ^privacy-policy/$ /parts/pages/privacy-policy.php [L,NC]
RewriteRule ^project/([^/]+)/$ /parts/pages/project.php?id=$1 [L,NC,QSA]
Make suer to clear your browser cache before you test this change.
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.
I have a site built with Contao. I just turned on URL rewriting and now index.php/foo returns a 404 error. I tried to rewrite /index.php/foo to /foo with
RewriteCond %{REQUEST_URI} ^/index\.php/
RewriteRule ^index.php/(.*) /$1 [R,L]
but it does not help.
Here's the rewrite part of the contao factory .htaccess with my additions in it's entirety (I edited out all the commented stuff to make it shorter):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/index\.php/ # My rule here
RewriteRule ^index.php/(.*) /$1 [R,L] # My rule here
<FilesMatch "\.(png|gif|jpe?g|js|css|ico|php|xml|csv|txt|gz|swf|flv|eot|woff|svg|ttf|htm)$">
RewriteEngine Off
</FilesMatch>
RewriteRule .*\.html$ index.php [L]
RewriteRule ^[a-z]{2}/$ index.php [L]
RewriteRule ^([a-z]{2})$ $1/ [R=301,L]
</IfModule>
What am I not getting here?
Never mind. I found the answer.
<FilesMatch "\.(png|gif|jpe?g|js|css|ico|THIS HERE CAUSED IT: --> ***php***|xml|csv|txt|gz|swf|flv|eot|woff|svg|ttf|htm)$">
RewriteEngine Off
</FilesMatch>
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
apache redirect from non www to www
I want my domain to redirect the non-www to the www version. For some reason the below code isn't working.
Any suggestions?
Most probably any easy fix, but I can't get it to work.
<ifmodule mod_deflate.c>
<filesmatch \.(css|html|js|php|xml)$>
setoutputfilter deflate
</filesmatch>
</ifmodule>
<ifmodule mod_security.c>
secfilterengine off
secfilterscanpost off
</ifmodule>
<ifmodule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^trailerpulse.com/
RewriteRule (.*) http://www.trailerpulse.com/$1 [R=301,L]
RewriteCond %{request_filename} -f
RewriteRule ^(.*) $1 [L]
RewriteRule ^([a-z]+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&q=$3 [L]
</ifmodule>
<ifmodule mod_expires.c>
ExpiresActive On
ExpiresDefault A0
<filesmatch \.(css|js|gif|jpe?g|png)$>
ExpiresDefault A604800
</filesmatch>
<filesmatch \.(html|xml)$>
ExpiresDefault A10800
</filesmatch>
</ifmodule>
FileEtag None
Options All -Indexes
ServerSignature Off
ErrorDocument 404 /error
Your rule is almost there. The only problem is that you have a trailing slash after the hostname, which would never appear in the "Host:" header of the request. Replace the / with $ and add [NC] flag to ignore case:
RewriteCond %{HTTP_HOST} ^trailerpulse.com$ [NC]
RewriteRule (.*) http://www.trailerpulse.com/$1 [R=301,L]