F|forbidden
Similar to Deny, this flag forces the server to immediately return a 403 Forbidden status code to the requesting browser or client for the request.
Example: Deny access to requests that end with exe:
RewriteRule .exe$ - [F]
G|gone
If a requested resource was available in the past,...
Redirect any naked domain to www.[your_domain].tld:
# Start Apache Rewriting engine
RewriteEngine On
# Make sure you're not already using www subdomain
# and that the host string is not empty
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\.
# We check for http/https connection ...
Search engines won't index your products if you have a URL like the following:
http://www.yourdomain.com/product.php?id=123
SEO friendly URL would look like http://www.yourdomain.com/123/product-name/. The following code helps achieve this without having to change product.php code.
RewriteEng...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ /$1/ [L,R=301]
The first RewriteCond helps exclude the files. The second RewriteCond checks if there is already a trailing slash. If the case is so RewriteRule is not applied.
If you have any URL that s...
Generic redirect to https:
# Enable Rewrite engine
RewriteEngine on
# Check if URL does not contain https
RewriteCond %{HTTPS} off [NC]
# If condition is true, redirect to https
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R=301,L]
Generic redirect to http:
# Enable Rewrite engine
Rewr...