Rewrite to https isn't working in .htaccess - .htaccess

I'm trying to configure new .htaccess file and everything seems to be working except HTTP redirect to HTTPS.
I've tried
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
But it didn't work. Here's my full .htaccess file in it's current form.
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Add Caching
<FilesMatch "\.(png|gif|js|css)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
</FilesMatch>
# disable directory autoindexing
Options -Indexes
RewriteEngine On
# https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BEGIN 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
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect to domain without www. for HTTPS:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]
# Stop hotlinking.
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} ^https?://([^/]+)/ [NC]
RewriteCond %1#%{HTTP_HOST} !^(.+)#\1$
RewriteRule \.(jpg|jpeg|png|gif|swf|svg)$ - [NC,F,L]
# Prevent viewing of htaccess file.
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
What am I missing?

Depending on your Host/Server configuration try
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
or
RewriteCond %{HTTPS} off
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [L,R=301]

Related

Redirect not works correctly

This simple rule should redirect to url without one word (picture-display):
RewriteRule en/catalog/picture-display/(.*)$ en/catalog/$1 [L,NC,R=302]
But it redirect from www.example.com/en/catalog/picture-display/something to www.example.com/en. What I am doing bad?
Before this rule I have this. Would not influence it?
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
EDIT
Whole .htaccess:
path/.htaccess
Header unset ETag
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(ico)$">
Header set Cache-Control "max-age=29030400"
</FilesMatch>
</IfModule>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^/?$ /public/index.php [L]
RewriteRule ^\.htaccess/?$ - [NC,F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$ [NC]
RewriteRule ^(.*)/?$ /public/$1
RewriteRule ^(cs/katalog)/obrazkove-zobrazeni/(.*)/?$ $1/$2 [L,NC,R=302]
RewriteRule ^(en/catalog)/picture-display/(.*)/?$ $1/$2 [L,NC,R=302]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [QSA,NC,L]
htaccess to route from documentRoute:
path/public/.htaccess (document route) - there is index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
Result of cmd
Please try add rule:
RewriteRule ^en/catalog/picture-display/(.*)$ en/catalog/$1 [L,NC,R=302]
before line with RewriteRule ^/?$ /public/index.php [L]
Please try following htaccess rules in your file. Please make sure to clear your browser cache before testing your URLs.
Header unset ETag
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(ico)$">
Header set Cache-Control "max-age=29030400"
</FilesMatch>
</IfModule>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [F,L]
RewriteCond %{REQUEST_URI} !^/public [NC]
RewriteRule ^(.*)/?$ /public/$1 [L]
RewriteRule ^/?$ /public/index.php [L]
RewriteRule ^public /public/index.php [QSA,NC,L]
RewriteRule ^\.htaccess/?$ - [NC,F]
RewriteRule ^(en/catalog)/picture-display/(.*)/?$ $1/$2 [L,NC,R=302]
RewriteRule ^(cs/katalog)/obrazkove-zobrazeni/(.*)/?$ $1/$2 [L,NC,R=302]
Keep your path/public/.htaccess (document route) like as follows:
RewriteOptions Inherit
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
Have it this way in your site root .htacccess:
RewriteEngine On
RewriteRule ^\.htaccess/?$ - [NC,F]
# add www and turn on https in same rule
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=302,L,NE]
RewriteRule ^(cs/katalog)/obrazkove-zobrazeni/(.*)/?$ /$1/$2 [L,NC,R=302]
RewriteRule ^(en/catalog)/picture-display/(.*)/?$ /$1/$2 [L,NC,R=302]
RewriteRule ^/?$ /public/index.php [L]
RewriteCond %{REQUEST_URI} !^/public/ [NC]
RewriteRule .* public/$0 [L]
Correct htaccess which do what I wanted is:
RewriteEngine On
RewriteRule ^cs/katalog/obrazkove-zobrazeni/(.*)/?$ /cs/katalog/$1 [L,NC,R=302]
RewriteRule ^en/catalog/picture-display/(.*)/?$ /en/catalog/$1 [L,NC,R=302]
RewriteRule ^\.htaccess/?$ - [NC,F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$ [NC]
RewriteRule ^(.*)/?$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [QSA,NC,L]
I would like to thank to #RavinderSingh13 and others which tried out help me, but their solutions didn't work unlike mine.

htaccess based redirect subdomain to folder in main domain

I have problem with my htaccess file.
My main domain kielkowski-szkolka.pl points to root folder
/kielkowski-szkolka.pl/public_html
Now, I created subdomain automatyka.kielkowski-szkolka.pl with points to /kielkowski-szkolka.pl/public_html/automatyka
Now when I try to go to automatyka.kielkowski-szkolka.pl it redirects me to / of my main domain, kielkowski-szkolka.pl
Can you look my root htaccess and tell me what to add/change to make it work?
SetEnv PHP_VER 5
php_flag apc.enabled On
php_flag apc.cache_by_default On
php_value session.gc_maxlifetime 86400
php_value session.cookie_lifetime 86400
Options +FollowSymLinks
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
#przekierowanie z http na https i z ww na bez www
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^kielkowski-szkolka.pl [NC]
RewriteRule ^(.*)$ https://kielkowski-szkolka.pl%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} !^on$
RewriteRule ^(.*)$ https://kielkowski-szkolka.pl/$1 [R=301,L]
# Redirect non-existing files or folders to index
# Redirect non-existing files or folders to index
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ / [L,QSA,R=301]
</IfModule>
You can check for your subdomain and then redirect to the folder like this for example.
RewriteCond %{HTTP_HOST} ^automatyka\.kielkowski-szkolka\.pl$
RewriteRule ^(.*)$ http://kielkowski-szkolka.pl/automatyka/$1 [L,R=301]

Remove Double trailing slash - open cart

i have been contiously upgrading my htaccess file. however, there are 2 issues I just cant seem to fix. I have tried several approaches but nothing really worked for me.
my website: https://www.zeroohm.com/
my questions:
How can I remove the extra trailing slash when i go to zeroohm.com
currently, if i go to zeroohm.com, it redirects to https://www.zeroohm.com//
if i go to www.zeroohm.com/robots.txt/ , it stops me from viewing my robots.txt file (an error occured while processing this directive). how can i fix this? this problem happens to sitemap.xml and it is causing problems with webmaster tool too.
C. any ideas on improving my re-directs?
my htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} ^zeroohm\.ae$ [OR]
RewriteCond %{HTTP_HOST} ^www\.zeroohm\.ae$
RewriteRule ^/?$ "http\:\/\/www\.zeroohm\.com\/\$1\/" [R=301,L]
# check if url has www or not, add www if not available. if avaiable dont do anything.
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) https://www.%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L]
#end
# force incoming traffic coming from HTTP to Https
RewriteCond %{HTTPS} !on$
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#end
#force trainling slash
RewriteBase /
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
#end of force trailing slash
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: http://www.opencart.com
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymlinks
Options +SymLinksIfOwnerMatch
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
# cache to keep it at client pc
<ifmodule mod_expires.c>
Expiresactive on
# set default
Expiresdefault "access plus 24 hours"
Expiresbytype image/jpg "access plus 1 months"
Expiresbytype image/gif "access plus 1 months"
Expiresbytype image/jpeg "access plus 1 months"
Expiresbytype image/png "access plus 1 months"
Expiresbytype text/css "access plus 1 months"
Expiresbytype text/javascript "access plus 1 months"
Expiresbytype application/javascript "access plus 1 months"
Expiresbytype application/x-shockwave-flash "access plus 1 months"
</ifmodule>
#gzip compression
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# SEO URL Settings
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
#libwww-perl security fix
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
RewriteCond %{THE_REQUEST} \ /index\.php\?_route_=?([^&\ ]*)
RewriteRule ^ /%1? [R=301,L]
You can keep these rules in your site root .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(?:www\.)?zeroohm\.ae$ [NC]
RewriteRule ^ http://www.zeroohm.com%{REQUEST_URI} [R=301,L,NE]
# check if url has www or not, add www if not available. if avaiable don't do anything.
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]
#force trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
#libwww-perl security fix
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule ^ - [F,L]
RewriteCond %{THE_REQUEST} \ /index\.php\?_route_=?([^&\s]*)
RewriteRule ^ /%1? [R=301,L]
RewriteRule ^sitemap\.xml$ index.php?route=feed/google_sitemap [L,QSA,NC]
RewriteRule ^googlebase\.xml$ index.php?route=feed/google_base [L,QSA,NC]
RewriteRule ^download/ /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule (.*) index.php?_route_=$0 [L,QSA]
Clear your browser cache before testing this change.

htaccess not redirecting properly with rewrite rules

I'm trying to create a simple htaccess file that does the following:
Redirects all http://domain.com to http://www.domain.com
Allows the '.php' extension to be dropped from file names
Allows http://www.domain.com/page/var and http://www.domain.com/page/var/ to be seen as http://www.domain.com/page?u=var
Rewrites all http://www.domain.com/page?u=var to http://www.domain.com/page/var
This is what I have so far, but it doesn't seem to be working:
IndexIgnore .htaccess
DirectoryIndex index.php
Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^([^/.]+)/?$ $1.php
RewriteRule page1/(.*)/$ /page1?u=$1
RewriteRule page1/(.*)$ /page1?u=$1
RewriteRule page2/(.*)/$ /page2?t=$1
RewriteRule page2/(.*)$ /page2?t=$1
ErrorDocument 400 http://www.domain.com/error?e=400
ErrorDocument 401 http://www.domain.com/error?e=401
ErrorDocument 403 http://www.domain.com/error?e=403
ErrorDocument 404 http://www.domain.com/error?e=404
ErrorDocument 500 http://www.domain.com/error?e=500
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
Any help would be appreciated, thanks.
Try this :
IndexIgnore .htaccess
DirectoryIndex index.php
Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
#Remove .php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^.]+)/?$ /$1.php [L,NC]
RewriteCond %{THE_REQUEST} /page\?u=([^\s]+)
RewriteRule ^ /page/%1? [NE,R,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ /page?u=$2 [L,NC]

Why .htaccess rewrite rule redirecting to unexpected url?

In my htacess I have:
RewriteRule ^(users)/([a-z]+)$ users.php?action=$2
When I type the url : site.com/users/register/ (yes with the / at the end)
the website redirects me to : site.com/users.php/register/?action=register
What is it doing that? when it should not redirect at all.
Also, when I type the url : site.com/users/register it sends me to error page!
full code:
Header unset ETag
FileETag None
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A86400
ExpiresByType image/x-icon A2592000
ExpiresByType image/ico A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType image/jpeg A604800
ExpiresByType text/plain A604800
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType video/x-flv A604800
ExpiresByType application/pdf A604800
ExpiresByType text/html A900
</IfModule>
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=7257600"
</FilesMatch>
# 1 Week
<FilesMatch "\.(js|css|pdf|txt)$">
Header set Cache-Control "max-age=7257600"
</FilesMatch>
# 10 Minutes
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=3600"
</FilesMatch>
<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>
#Gzip
<ifmodule mod_deflate.c>
# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# remove browser 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
</ifmodule>
#End Gzip
# NONE
<FilesMatch "\.(pl|php|cgi|spl)$">
Header unset Cache-Control
Header unset Expires
Header unset Last-Modified
FileETag None
Header unset Pragma
</FilesMatch>
ErrorDocument 404 http://www.site.ae
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(RSS)/([A-Z][a-zA-z0-9]+).xml$ rss.php?title=$2
RewriteRule ^(articles)/(.*)/$ article.php?s=$2
RewriteRule ^(articles)/(.*)/([0-9]+)$ article.php?s=$2&page=$3
RewriteRule ^(teams)/(.*)/$ teams.php?s=$2
RewriteRule ^(teams)/(.*)/([0-9]+)$ teams.php?s=$2&page=$3
RewriteRule ^(site)/(all)/$ site.php?s=$2
RewriteRule ^(site)/(all)/([0-9]+)$ site.php?s=$2&page=$3
RewriteRule ^(site)/(tag)/(.*)/(.*)/([A-Z]+)/([0-9]+)$ site.php?s=tag&orderby=$4&order=$5&tag=$3&page=$6
RewriteRule ^(site)/(.*)/(.*)/([A-Z]+)/([0-9]+)$ site.php?s=$2&orderby=$3&order=$4&page=$5
RewriteRule ^([A-Z][a-zA-z0-9]+)/?$ show_site.php?title=$1
RewriteRule ^([A-Z][a-zA-z0-9]+)/([0-9]+)/([0-9]+)/?$ show_chapter.php?title=$1&ch_num=$2&page=$3
RewriteRule ^([A-Z][a-zA-z0-9]+)/([0-9]+)/?$ show_chapter.php?title=$1&ch_num=$2&page=C
RewriteRule ^(t)/(.*)/$ team.php?t=$2
RewriteRule ^(t)/(.*)/([0-9]+)$ team.php?t=$2&page=$3
RewriteRule ^(contact)/?$ contact.php
RewriteRule ^(add)/(chapter)?$ addchapter.php
RewriteRule ^(add)/(site)?$ addsite.php
RewriteRule ^(add)/(info)?$ addinfo.php
RewriteRule ^(register)/?$ register.php
RewriteRule ^(user)/(.*)/$ usercp.php?page=favorite&user=$2
RewriteRule ^(my-list)/delete/([0-9]+)/$ usercp.php?page=delete&site=$2
RewriteRule ^(my-list)/add/([0-9]+)/$ usercp.php?page=add&site=$2
RewriteRule ^(review)/([A-Z][a-zA-z0-9]+)/$ addreview.php?m=$2
RewriteRule ^(users)/([a-z]+)$ users.php?action=$2
RewriteRule ^(showarticle)/([0-9]+)/$ showarticle.php?id=$2
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?siteat.com
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?site.ae [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://i642.photobucket.com/albums/uu145/shnisaka/nohotlinking_zpsf5dd3133.jpg [NC,R,L]
RewriteCond %{HTTP_HOST} ^site.ae$
RewriteRule ^(.*)$ "http\:\/\/www\.site\.ae\/$1" [R=301,L]
More refined question:
RewriteRule ^(users)/(register)$ users.php?action=register [R=301,L]
should redirect from site.com/users.php?action=register to site.com/users/register right?
Keep your rule like this:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?siteat\$.com
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?site\.ae$ [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://i642.photobucket.com/albums/uu145/shnisaka/nohotlinking_zpsf5dd3133.jpg [NC,R,L]
RewriteCond %{HTTP_HOST} ^site\.ae$
RewriteRule ^(.*)$ http://www.site.ae/$1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^(RSS)/([A-Z][a-zA-z0-9]+).xml$ rss.php?title=$2 [L,QSA]
RewriteRule ^(articles)/(.*)/$ article.php?s=$2 [L,QSA]
RewriteRule ^(articles)/(.*)/([0-9]+)$ article.php?s=$2&page=$3 [L,QSA]
RewriteRule ^(teams)/(.*)/$ teams.php?s=$2 [L,QSA]
RewriteRule ^(teams)/(.*)/([0-9]+)$ teams.php?s=$2&page=$3 [L,QSA]
RewriteRule ^(site)/(all)/$ site.php?s=$2 [L,QSA]
RewriteRule ^(site)/(all)/([0-9]+)$ site.php?s=$2&page=$3 [L,QSA]
RewriteRule ^(site)/(tag)/(.*)/(.*)/([A-Z]+)/([0-9]+)$ site.php?s=tag&orderby=$4&order=$5&tag=$3&page=$6 [L,QSA]
RewriteRule ^(site)/(.*)/(.*)/([A-Z]+)/([0-9]+)$ site.php?s=$2&orderby=$3&order=$4&page=$5 [L,QSA]
RewriteRule ^([A-Z][a-zA-z0-9]+)/?$ show_site.php?title=$1 [L,QSA]
RewriteRule ^([A-Z][a-zA-z0-9]+)/([0-9]+)/([0-9]+)/?$ show_chapter.php?title=$1&ch_num=$2&page=$3 [L,QSA]
RewriteRule ^([A-Z][a-zA-z0-9]+)/([0-9]+)/?$ show_chapter.php?title=$1&ch_num=$2&page=C [L,QSA]
RewriteRule ^(t)/(.*)/$ team.php?t=$2 [L,QSA]
RewriteRule ^(t)/(.*)/([0-9]+)$ team.php?t=$2&page=$3 [L,QSA]
RewriteRule ^(contact)/?$ contact.php [L,QSA]
RewriteRule ^(add)/(chapter)?$ addchapter.php [L]
RewriteRule ^(add)/(site)?$ addsite.php [L]
RewriteRule ^(add)/(info)?$ addinfo.php [L]
RewriteRule ^(register)/?$ register.php [L]
RewriteRule ^(user)/(.*)/?$ usercp.php?page=favorite&user=$2 [L,QSA]
RewriteRule ^(my-list)/delete/([0-9]+)/?$ usercp.php?page=delete&site=$2 [L,QSA]
RewriteRule ^(my-list)/add/([0-9]+)/?$ usercp.php?page=add&site=$2 [L,QSA]
RewriteRule ^(review)/([A-Z][a-zA-z0-9]+)/?$ addreview.php?m=$2 [L,QSA]
RewriteRule ^(users)/([a-z]+)/?$ users.php?action=$2 [L,QSA]
RewriteRule ^(showarticle)/([0-9]+)/?$ showarticle.php?id=$2 [L,QSA]
RewriteRule ^users/([a-z]+)/?$ users.php?action=$1
RewriteRule ^users/activate/([a-zA-Z0-9]+)/([a-z]+)/?$ users.php?action=activate&Hash=$1&UserName=$2
RewriteCond %{THE_REQUEST} users\.php
RewriteRule ^users\.php - [F]
I had to delete my .htaccess and add this to it. It worked with no problems!

Resources