.htaccess redirect http to https

I use the following to successfully redirect all pages of my domain from http to https: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] Note this will redirect using the 301 ‘permanently moved’ redirect, which will help transfer your SEO rankings. To redirect using the 302 ‘temporarily moved’ change [R=302,L]

How to deny access to a file in .htaccess

Within an htaccess file, the scope of the <Files> directive only applies to that directory (I guess to avoid confusion when rules/directives in the htaccess of subdirectories get applied superceding ones from the parent). So you can have: <Files “log.txt”> Order Allow,Deny Deny from all </Files> For Apache 2.4+, you’d use: <Files “log.txt”> Require all … Read more

Make .git directory web inaccessible

Put this in an .htaccess file at the root of your web server: RedirectMatch 404 /\.git This solution is robust and secure: it works for all .git directories in your site, even if there are more than one, also hides other Git files like .gitignore and .gitmodules works even for newly-added .git directories, and doesn’t … Read more

How to prevent http file caching in Apache httpd (MAMP)

Tried this? Should work in both .htaccess, httpd.conf and in a VirtualHost (usually placed in httpd-vhosts.conf if you have included it from your httpd.conf) <filesMatch “\.(html|htm|js|css)$”> FileETag None <ifModule mod_headers.c> Header unset ETag Header set Cache-Control “max-age=0, no-cache, no-store, must-revalidate” Header set Pragma “no-cache” Header set Expires “Wed, 11 Jan 1984 05:00:00 GMT” </ifModule> </filesMatch> … Read more

URL rewriting with PHP

You can essentially do this 2 ways: The .htaccess route with mod_rewrite Add a file called .htaccess in your root folder, and add something like this: RewriteEngine on RewriteRule ^/?Some-text-goes-here/([0-9]+)$ /picture.php?id=$1 This will tell Apache to enable mod_rewrite for this folder, and if it gets asked a URL matching the regular expression it rewrites it … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)