phanan / htaccess Goto Github PK
View Code? Open in Web Editor NEW✂A collection of useful .htaccess snippets.
License: Other
✂A collection of useful .htaccess snippets.
License: Other
Unsecure redirect. Read about http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security
Hi Phanan,
Can i make translate to portuguese Brazil ? Because very important for everyone, so going help many folks.
Where you have
Order Allow,Deny
Deny from whatever
This is a bit redundant , since the default is Deny in this case if no Allow rule is matched - source
Is this by design , just to be thorough ?
I found this rule here - https://stackoverflow.com/questions/20631015/force-www-in-htaccess-except-all-subdomains
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[0-9a-zA-Z-]+\.[a-zA-Z]{2,}$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
I get a double slash at the end of the url if i type in an address like server.lan/
So I changed it a bit to look like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[0-9a-zA-Z-]+\.[a-zA-Z]{2,}$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
I don't know if it's good though. I made a quick test and it looks ok.
Hi,
How to redirect git submoudle from kerberos url to htto url.
No issues with HTTP to HTTP.
Thanks
Is it possible to minify the class names inside CSS, HTML and JavaScript ? Like what we see in google.
like : .ga, .cb
etc..
I'm not sure is that possible via .htaccess, but would be a great addition.
First off, awesome snippet collection! Very useful.
One thing I want to note however is having a space between deny,allow or allow,deny will throw back a server error. The space in between those (deny, allow) should be removed (deny,allow).
Thanks.
Can't get this to handle the case when a user enters www and a subdomain over HTTPS.
NOT WORKING:
https://www.mysubdomain.mydomain.com --> https://mysubdomain.mydomain.com
WORKING:
http://www.mysubsomain.mydomain.com --> https://mysubsomain.mydomain.com
php_value date.timezone 'Region/Zone'
I disagree with the line
It's actually recommended to remove www from your domain. Surprise surprise!
at https://github.com/phanan/htaccess#force-non-www
While one might choose to omit the www from a branding perspective, from a technical perspective it is generally preferable to redirect to the www version of the site.
Related Articles
Overall, this is a great resource. Thanks.
I have the following 2 links, Please some one help me
I want to redirect this page http://www.mywebsite.co.uk/category-of-mobile/any-words/?id=smob_qs&fromDate=&parts=
to another page http://www.mywebsite.co.uk/category-of-mobile/any-words/smob_qs
Note:
So i need http://www.mywebsite.co.uk/category-of-mobile/any-words/smob_qs Url
Please help me using htaccess
There were actually some breaking changes in the .htaccess syntax if you upgrade apache from 2.2 to 2.4. Check this page for a full list.
The most commonly problem is with the access control:
From:
Order deny,allow
Deny from all
To
Require all denied
The 'Allow All Access Except Spammers' snippet didn't work as I expected: the Deny settings were ignored; eveyone was allowed access.
Having read the documentation I think the explicit Allow from all
line overrides the denials and should be removed.
The optional includeSubDomains
flag will enforce HTTPS on all subdomains. Any subdomain that will not have HTTPS will be blocked by the browser. Clearing the "cache" for HSTS is very complicated. As the max-age
is set to one year, this can have a massive negative effect, if you, for whatever reason, need to have a subdomain on any server without HTTPS.
@phanan Quite a lot of the things from this repository are basically taken from an older version of the .htaccess
file provided by the Apache Server Configs project. So, I think it would be nice of you to make that obvious and give credit where credit is due (e.g.: there is no link to the Apache Server Configs project, and also some of the "Source" links don't even work, or point to a different project such as HTML5 Boilerplate, that is just another project that uses the Apache server configs).
Also, keep in mind that while you are free to copy and use the code, by not giving credit to the people that invested their free time to do the research to create the code, you make them less willing to do so in the future.
Hola, creo que faltó esto:
Header set X-Robots-Tag "noindex, nofollow"
The Flattr page for this repo is unclaimed but already has some donations waiting four you, @phanan.
Please consider adding some snippets for those not in the cult of www, but who would prefer to display domain uncluttered in URI.
Plainly I am not advocating contrawwwism.
[contratheism]
There is room for http://no-www.org and cultists alike. Evidently there is more space for the former as it consumes fewer bits.
https://github.com/phanan/htaccess#deny-access-to-hidden-files-and-directories
Instead of:
RedirectMatch 404 /\..*$
your example could be:
RedirectMatch 404 /\.(?!well-known\/)
Useful for:
A proposed standard which allows websites to define security policies.
https://securitytxt.org/
Private prefetch proxy in Chrome
https://developer.chrome.com/blog/private-prefetch-proxy/#traffic
Other uses:
https://www.iana.org/assignments/well-known-uris/well-known-uris.xhtml
Can anyone confirm that the 'Serve WebP Images' snippet actually works? Tested it out in Chrome with some WebP images in same directory as JPEGS and with identical names (apart from file extension obviously) and Chrome never uses the WebP replacement for me.
Hello, I wrote a tool that can validate README links (valid URLs, not duplicate). It can be run when someone submits a pull request.
It is currently being used by
Examples
If you are interested, connect this repo to https://travis-ci.org/ and add a .travis.yml
file to the project.
See https://github.com/dkhamsing/awesome_bot for options, more information
Feel free to leave a comment 😄
Hi!
I thought it is best to include resources related so everyone can have rich knowledge about the configuration. Here is my list which I've compiled through Google, articles, repositories, and official documentation.
API References:
https://httpd.apache.org/docs/trunk/howto/htaccess.html
https://httpd.apache.org/docs/trunk/mod/quickreference.html
https://httpd.apache.org/docs/trunk/mod/mod_rewrite.html
https://httpd.apache.org/docs/trunk/expr.html
Collection:
https://github.com/phanan/htaccess
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Apache_Configuration_htaccess
https://github.com/h5bp/server-configs-apache
Article:
https://httpd.apache.org/docs/2.4/rewrite/
https://www.askapache.com/htaccess/
https://www.askapache.com/htaccess/crazy-advanced-mod_rewrite-tutorial/
https://wordpress.org/support/article/htaccess/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.