I receive 404 server error when submit https://example.com/.../image.png as value from a html form. When submit the same url with http:// (not secured url) everything works fine.
Is there any restriction to submit https:// urls as value of a form field?
My .htaccess file:
redirect 301 /category/новини/ http://barimax.bg/новини/
ErrorDocument 404 /index.php?id=404
# Enable GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifmodule>
# Expires Headers - 2678400s = 31 days
<ifmodule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 7200 seconds"
ExpiresByType image/gif "access plus 2678400 seconds"
ExpiresByType image/jpeg "access plus 2678400 seconds"
ExpiresByType image/png "access plus 2678400 seconds"
ExpiresByType text/css "access plus 518400 seconds"
ExpiresByType text/javascript "access plus 2678400 seconds"
ExpiresByType application/x-javascript "access plus 2678400 seconds"
</ifmodule>
# Cache Headers
<ifmodule mod_headers.c>
# Cache specified files for 31 days
<filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
Header set Cache-Control "max-age=2678400, public"
</filesmatch>
# Cache HTML files for a couple hours
<filesmatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, private, must-revalidate"
</filesmatch>
# Cache PDFs for a day
<filesmatch "\.(pdf)$">
Header set Cache-Control "max-age=86400, public"
</filesmatch>
# Cache Javascripts for 31 days
<filesmatch "\.(js)$">
Header set Cache-Control "max-age=2678400, private"
</filesmatch>
</ifmodule>
RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !ckfinder.html
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ https://barimax.bg/$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#RewriteCond %{HTTP_HOST} ^barimax.bg [NC,OR]
#RewriteCond %{HTTP_HOST} ^www.barimax.bg .com [NC]
#RewriteRule ^(.*)$ https://www.barimax.bg/$1 [L,R=301,NC]
AuthName "www"
AuthUserFile "/home/barimax/.htpasswds/public_html/passwd"
AddHandler application/x-httpd-php54 .php54 .php
Related
My main website is:
http://sandybeachit.co.uk
I have a wordpress site setup at my addon-domain:
[http://imadeitviral.com][1]
The wordpress site is in:
/hosting/imadeitviral
The above address can be found here on the primary site under sandybeachit.co.uk/hosting/imadeitviral/
I have got the site url and home set to "http:// imadeitviral.com" (without the space between "http:// and madeitviral.com"
But when you go imadeitviral.com the site attempts to load my primary site at sandybeachit.co.uk except the site does not load correctly, you can try it and your see what i mean.
If i set the wordpress site url and home to pointing to "sandybeachit.co.uk/hosting/imadeitviral" the site will load fine, so i know i have got something wrong, but i can not figure out what.
I have tried removing the .htaccess file in my main domain and editing it so i an sure its not that is the problem as well as the .htaccess file in the wordpress folder.
I did the install via Site Software Softaculous Apps Installer
Can i get some pointers as to what i have done wrong or missed ?
Thanks
HTACCESS FILE IN WORDPRESS DIRECTORY:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /hosting/imadeitviral/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /hosting/imadeitviral/index.php [L]
</IfModule>
# END WordPress
HTACCESS FILE IN MAIN DIRECTORY:
RewriteCond %{HTTP_HOST} ^(www\.)?imadeitviral\.com
RewriteRule .* - [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ /$1.php [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .*[^/]$ /$0/ [L,R=301]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#RULES ADDED AFTER 14TH JANUARY 2017
# Set Timezone
<IfModule !fcgid_module>
php_value date.timezone "Europe/London"
</IfModule>
# Disable directory browsing
Options All -Indexes
### Security - Disable HTTP Track and Trace
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
# STRONG HTACCESS PROTECTION
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>
#DENY ACCESS - START
<FilesMatch "config.php|\.tpl$">
Order allow,deny
Deny from all
</FilesMatch>
#DENY ACCESS - END
# One year for image files
<filesMatch ".(jpg|jpeg|png|gif|ico)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
# One month for css and js
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$">
Header set Expires "Thu, 15 Apr 2012 20:00:00 GMT"
Header unset ETag
FileETag None
</FilesMatch>
# BEGIN EXPIRES
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 days"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# END EXPIRES
# GZIP BEGIN - COMPRESS - .CSS .JS .HTML .XHTML .PHP .TXT
#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x- javascript application/javascript
</ifmodule>
#End Gzip
<IfModule mod_deflate.c>
#The following line is enough for .js and .css
AddOutputFilter DEFLATE js css
#The following line also enables compression by file content type, for the following list of Content-Type:s
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml
#The following lines are to avoid bugs with some browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
<ifModule mod_headers.c>
Header unset Vary
Header set Vary "Accept-Encoding, X-HTTP-Method-Override, X-Forwarded-For, Remote-Address, X-Real-IP, X-Forwarded-Proto, X-Forwarded-Host, X-Forwarded-Port, X-Forwarded-Server"
</ifModule>
After a little more testing:
What i am finding is if i goto:
imadeitviral.com/
The site loads
As soon as i go into:
imadeitviral.com/wp-admin
after a short while the site times out to a 404 with the message:
"Not Found
The requested URL /wp-admin/plugins.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
I'm trying to move my wordpress blog to https, however I tried many things but all of them give me a redirect loop error.
This is my current htaccess:
# 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
<IfModule mod_deflate.c>
#The following line is enough for .js and .css
AddOutputFilter DEFLATE js css
AddOutputFilterByType DEFLATE text/plain text/xml application/xhtml+xml text/css application/xml application/rss+xml application/atom_xml application/x-javascript application/x-httpd-php application/x-httpd-fastphp text/html
#The following lines are to avoid bugs with some browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
# BEGIN EXPIRES
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 days"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# END EXPIRES
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary Accept-Encoding
</FilesMatch>
<FilesMatch "\.(ico|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
<FilesMatch "\.(css)$">
Header set Cache-Control "public"
</FilesMatch>
<FilesMatch "\.(js)$">
Header set Cache-Control "private"
</FilesMatch>
<FilesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</FilesMatch>
</IfModule>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
# Wordfence WAF
<Files ".user.ini">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Files>
# END Wordfence WAF
And i added this to wp-config.php:
/* SSL Settings */
define('FORCE_SSL_ADMIN', true);
/* Turn HTTPS 'on' if HTTP_X_FORWARDED_PROTO matches 'https' */
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
$_SERVER['HTTPS'] = 'on';
This are the different variants I tried to redirect to https:
Variant 1:
RewriteCond %{HTTPS} off
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
Variant 2
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://example.com/$1 [R,L]
Variant 3
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA,L]
All of them give me a redirect loop, any idea how I can fix this?
Thanks
Just fixed it with Really Simple SSL plugin for wordpress, If anyone is having this problem I recommend you try it.
You shouldn't need to use a plugin nor touch the .htaccess of your WordPress installation to get it to work on HTTPS. Change the Site and WordPress URLs in the admin area within Settings > General.
Here is a useful guide on how to change the site URLs.
You can also just force it within the admin area only by putting the following in your config.php file (in the WordPress root), although having it everywhere is best.
define('FORCE_SSL_ADMIN', true);
Generally though, I'd avoid using a plugin for something like this which can be done natively and easily too.
htaccess rule for subfolder
Options +Includes
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifmodule>
# Expires Headers - 2678400s = 31 days
<ifmodule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 7200 seconds"
ExpiresByType image/gif "access plus 2678400 seconds"
ExpiresByType image/jpeg "access plus 2678400 seconds"
ExpiresByType image/png "access plus 2678400 seconds"
ExpiresByType text/css "access plus 518400 seconds"
ExpiresByType text/javascript "access plus 2678400 seconds"
ExpiresByType application/x-javascript "access plus 2678400 seconds"
</ifmodule>
# Cache Headers
<ifmodule mod_headers.c>
# Cache specified files for 31 days
<filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
Header set Cache-Control "max-age=2678400, public"
</filesmatch>
# Cache HTML files for a couple hours
<filesmatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, private, must-revalidate"
</filesmatch>
# Cache PDFs for a day
<filesmatch "\.(pdf)$">
Header set Cache-Control "max-age=86400, public"
</filesmatch>
# Cache Javascripts for 31 days
<filesmatch "\.(js)$">
Header set Cache-Control "max-age=2678400, private"
</filesmatch>
</ifmodule>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteRule ^home index.php [NC,L]
RewriteRule ^promo/offers/([0-9]+)/([^/]+)/?$ off.php?pid=$1&ct=$2 [L]
file path is http://localhost/ct/test/off.php?no=1&no2=abc
i want http://localhost/ct/promo/offers/12/abc
this rule doesn't work properly so please tell me what to do.
error is Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
I am using laravel 5, for speed I test in google speed insight, its showing leverage browser caching
to solve that I have used following .htaccess code but non of them are working
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?params=$1 [L,QSA]
</IfModule>
<IfModule mod_headers.c>
# Serve gzip compressed CSS files if they exist
# and the client accepts gzip.
RewriteCond "%{HTTP:Accept-encoding}" "gzip"
RewriteCond "%{REQUEST_FILENAME}\.gz" -s
RewriteRule "^(.*)\.css" "$1\.css\.gz" [QSA]
# Serve gzip compressed JS files if they exist
# and the client accepts gzip.
RewriteCond "%{HTTP:Accept-encoding}" "gzip"
RewriteCond "%{REQUEST_FILENAME}\.gz" -s
RewriteRule "^(.*)\.js" "$1\.js\.gz" [QSA]
# Serve correct content types, and prevent mod_deflate double gzip.
RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1]
RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1]
<FilesMatch "(\.js\.gz|\.css\.gz)$">
# Serve correct encoding type.
Header append Content-Encoding gzip
# Force proxies to cache gzipped &
# non-gzipped css/js files separately.
Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"
# Media: images, video, audio
ExpiresByType assets/images "access plus 1 month"
# CSS and JavaScript
ExpiresByType assets/css "access plus 1 month"
ExpiresByType assets/js "access plus 1 month"
<IfModule mod_headers.c>
Header append Cache-Control "public"
</IfModule>
</IfModule>
Second code that I used in .htaccess is this one
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?params=$1 [L,QSA]
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 year"
ExpiresByType text/html "access plus 1 second"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
</IfModule>
I also tried this one code in .htaccess to make it work, but this one is also not working
<IfModule mod_expires.c>
# Set Cache-Control and Expires headers
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$">
Header set Cache-Control "max-age=2592000, public"
Header set Expires "1 day"
</filesMatch>
<filesMatch "\\.(css|css.gz)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch "\\.(js|js.gz)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch "\\.(xml|txt)$">
Header set Cache-Control "max-age=216000, public, must-revalidate"
</filesMatch>
<filesMatch "\\.(html|htm)$">
Header set Cache-Control "max-age=7200, public, must-revalidate"
</filesMatch>
</IfModule>
I have used all above code but I got same result every time
should fix: Leverage browser caching
on most of the anaylser.
is anything I am missing in this
If You are in ubuntu try this
sudo a2enmod expires
sudo systemctl restart apache2
Check that modules are enable in server.
If modules are not enabled than code will not work.
I need some help with an htaccess file:
Options -Indexes
Options +FollowSymLinks
DirectoryIndex index.html index.htm index.asp index.php
ErrorDocument 401 http://www.domainname.com
ErrorDocument 403 http://www.domainname.com
ErrorDocument 404 http://www.domainname.com
ErrorDocument 500 http://www.domainname.com
ErrorDocument 507 http://www.domainname.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domainname.com$
RewriteRule ^(.*) http://domainname.com/$1 [QSA,L,R]
RewriteRule ^(.*/)?index\.([a-zA-Z0-9]{3,4})$ /$1 [R=301,L]
RewriteRule ^(.*)\.htm$ $1.php [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index1.php?/$1 [L]
AddType text/html .html .htm .asp
AddType text/css .css
AddType image/vnd.microsoft.icon .ico
AddType image/jpeg .jpg
ExpiresActive on
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 3 months"
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>
# compress the files
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
# removes some bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
I have this line in my htaccess file RewriteRule ^(.*/)?index\.([a-zA-Z0-9]{3,4})$ /$1 [R=301,L] at the moment it will direct any visit I receive on a index file to the root of that file so a hit on
http://www.domainname.com/index.asp will become http://www.domainname.com/ which is exactly what I want. However if the domain is hit on a subfolder with an index file it will only show the directory and not the page name as well: http://www.domainname.com/folder1/folder2/index.asp will become http://www.domainname.com/folder1/folder2/ which is not what I want.
How do I fix it so that RewriteRule ^(.*/)?index\.([a-zA-Z0-9]{3,4})$ /$1 [R=301,L] will only redirect the to the root if it is hit on http://www.domainname.com/index.asp and not on all directories.
Thanks!
The first part of your rewrite rule regex is matching anything up to a / (or not). We can remove that part and just have it take effect on the root directory.
RewriteRule ^index\.([a-zA-Z0-9]{3,4})$ / [R=301,L]