I want to force HTTP for one page i.e. preview.php. Rest the website can use HTTPS. Because preview.php has an iframe which loads the content from NON-Secured locations. And hence do not display on a secured page.
I have tried several solutions here on Stack Overflow but didn't work. Any suggestion will be appreciated. My code as follows:
If there is any mistake in code below. Please me know.:
I have tried the following solutions mentioned here :
Force HTTPS on certain URLs and force HTTP for all others
Force https for some pages and http for all others
How to force rewrite to HTTPS except for a few pages in Apache?
Using .htaccess to control HTTPS on certain pages
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$">
ExpiresActive On
ExpiresDefault A432000
</FilesMatch>
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
SetEnvIfNoCase User-Agent "^libwww-perl*" block_bad_bots
Deny from env=block_bad_bots
# index.php to /
RewriteCond %{THE_REQUEST} ^GET\ /.*/index\.(php|html)\ HTTP
RewriteRule (.*)index\.(php|html)$ /$1 [R=301,L]
# force www.
RewriteCond %{HTTP_HOST} ^www\.domain\.co [NC]
RewriteRule ^(.*)$ http://domain.co/$1 [L,R=301]
RewriteCond %{HTTPS} ^off$
RewriteCond %{REQUEST_URI} !preview\.php$
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
#RewriteCond %{HTTPS} off
#RewriteCond %{REQUEST_URI} !/preview
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,NE,L]
RewriteRule ^profile/(.+)$ profile.php?username=$1 [L,NC,QSA]
RewriteRule ^dashboard/(.+)$ dashboard.php?option=$1 [L,NC,QSA]
RewriteRule ^theme/([a-zA-Z0-9-/]+).html$ theme.php?themename=$1
RewriteRule ^theme/([a-zA-Z0-9-/]+).html/$ theme.php?themename=$1
RewriteRule ^preview/([a-zA-Z0-9-/]+).html$ preview.php?themename=$1
RewriteRule ^preview/([a-zA-Z0-9-/]+).html/$ preview.php?themename=$1
RewriteRule ^category/([0-9]+)$ category.php?page=$1
RewriteRule ^category/([0-9]+)/$ category.php?page=$1
RewriteRule ^category/([a-zA-Z0-9_-]+)$ category.php?cat=$1
RewriteRule ^category/([a-zA-Z0-9_-]+)/$ category.php?cat=$1
RewriteRule ^category/([a-zA-Z0-9_-]+)/([0-9]+)$ category.php?cat=$1&page=$2
RewriteRule ^category/([a-zA-Z0-9_-]+)/([0-9]+)/$ category.php?cat=$1&page=$2
RewriteRule ^category/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([0-9]+)$ category.php?cat=$1&subcat=$2&page=$3
RewriteRule ^category/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([0-9]+)/$ category.php?cat=$1&subcat=$2&page=$3
RewriteRule ^category/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ category.php?cat=$1&subcat=$2
RewriteRule ^category/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ category.php?cat=$1&subcat=$2
RewriteRule ^header.php page-not-found.php [R=301,L]
RewriteRule ^footer.php page-not-found.php [R=301,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
<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>
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# # Remove browser bugs (only needed for really old browsers)
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>
ErrorDocument 404 /page-not-found.php
Related
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]
domain.com - live server
dev.domain.com - dev server
Both with:
/public/robots.txt #which is for domain.com
/public/robots-dev.txt #which is for dev.domain.com
.htaccess
How to use the same .htaccess to select specific robots depending if it in live or dev?
I have tried this, but it is not working (part of the htaccess is to redirect non-https & www to https with non-www, please ignore that):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
RewriteRule ^(.*)$ public/$1 [L]
RewriteRule ^robots\.txt$ /robots-%1\.txt [L] #this one
</IfModule>
Update: Below is the public/.htaccess
# GLOBAL RULES
# ============
# Directories Index protection
Options -Indexes
# Remove index.php from URL
<IfModule mod_rewrite.c>
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
</IfModule>
# Default Apache rules
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# Robots.txt
RewriteRule ^(robots\.txt)$ /robots [NC,L]
# Iframe calling
<IfModule mod_headers.c>
Header unset X-Frame-Options
</IfModule>
# GTMetrix - Enable gzip compression
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
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>
# GTMetrix - Enable gzip compression
# GTMetrix Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/svg "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/json "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType text/x-javascript "access plus 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 1 month"
</IfModule>
# GTMetrix Browser Caching
You may use these rules:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
RewriteCond %{HTTP_HOST} ^dev\. [NC]
RewriteRule ^robots\.txt$ public/robots-dev.txt [L,NC]
RewriteRule ^(?!public/)(.*)$ public/$1 [L,NC]
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]
I'm trying to make a 410 (gone) to all com_k2 links that for some reason are pointing towards my site, but the WordPress part of htaccess (I mean # BEGIN WordPress - # END WordPress) overrides it and I can't make it work.
This is what I have at the top of site:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^www.mypage.com
RewriteCond %{QUERY_STRING} com_k2 [NC]
RewriteRule ^ - [G,L]
then at the bottom WP makes this:
# 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>
The pattern is this:
https://www.mypage.com/?option=com_k2&view=itemlist&task=user&id=5640
I'm no htaccess expert so... help!
This is the full htaccess:
# BEGIN WpFastestCache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?mitza\.es
RewriteCond %{QUERY_STRING} com_k2 [NC]
RewriteRule ^ - [G]
# Start WPFC Exclude
# End WPFC Exclude
# Start_WPFC_Exclude_Admin_Cookie
RewriteCond %{HTTP:Cookie} !wordpress_logged_in_[^\=]+\=mitza#mitza.es
# End_WPFC_Exclude_Admin_Cookie
RewriteCond %{HTTP_HOST} ^www.mitza.es
RewriteCond %{HTTP_USER_AGENT} !(facebookexternalhit|WhatsApp|Mediatoolkitbot)
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{REQUEST_URI} !(\/){2}$
RewriteCond %{QUERY_STRING} !.+
RewriteCond %{HTTP:Cookie} !comment_author_
RewriteCond %{HTTP:Cookie} !wp_woocommerce_session
RewriteCond %{HTTP:Cookie} !safirmobilswitcher=mobil
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/all/$1/index.html -f [or]
RewriteCond /home/mitzaes/public_html/wp-content/cache/all/$1/index.html -f
RewriteRule ^(.*) "/wp-content/cache/all/$1/index.html" [L]
</IfModule>
<FilesMatch "index\.(html|htm)$">
AddDefaultCharset UTF-8
<ifModule mod_headers.c>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Mon, 29 Oct 1923 20:30:00 GMT"
</ifModule>
</FilesMatch>
# END WpFastestCache
# BEGIN GzipWpFastestCache
<IfModule mod_deflate.c>
AddType x-font/woff .woff
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/opentype font/ttf font/eot font/otf
</IfModule>
# END GzipWpFastestCache
# BEGIN LBCWpFastestCache
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|webp|js|css|swf|x-html|css|xml|js|woff|woff2|ttf|svg|eot)(\.gz)?$">
<IfModule mod_expires.c>
AddType application/font-woff2 .woff2
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/webp A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType image/svg+xml A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000
ExpiresByType application/javascript A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType application/font-woff2 A2592000
</IfModule>
<IfModule mod_headers.c>
Header set Expires "max-age=2592000, public"
Header unset ETag
Header set Connection keep-alive
FileETag None
</IfModule>
</FilesMatch>
# END LBCWpFastestCache
# 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
# BEGIN Brute Force Login Protection
<FilesMatch ".*\.(php|html?|css|js|jpe?g|png|gif)$">
order deny,allow
deny from 91.200.12.22
deny from 91.200.12.91
deny from 2607:f298:5:101b::61e:49ae
</FilesMatch>
# END Brute Force Login Protection
RewriteEngine on
Redirect 301 /nuevo-nicehash-miner-legacy https://www.mitza.es/noticias/nuevo-nicehash-miner-legacy
Redirect 301 /secciones/bitcoin/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /secciones/litecoin/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /portfolio/gibson-guitars/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /portfolio/nex7-workspace/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /how-videos-can-help-promote-your-business/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /working-like-a-workaholic/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /portfolio/focus-lab/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /portfolio/outdoor-photoshoot/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /portfolio/l-a-p-d-1947/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /audio-post/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /perfect-sunday-morning-ride/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /secciones/noticias/ https://www.mitza.es/noticias
#2
Redirect 301 /logic-will-get-you-from-a-to-b/ https://www.mitza.es/
Redirect 301 /component/content/article/2-uncategorised/80-para-costi https://www.mitza.es
Redirect 301 /role-of-size-in-logo-design/ https://www.mitza.es/
Redirect 301 /portfolio/its-summer-time/ https://www.mitza.es/
Redirect 301 /portfolio/maybe-one-day-fashion/ https://www.mitza.es/
Redirect 301 /hello-world-2/ https://www.mitza.es/
Redirect 301 /hola-mundo/ https://www.mitza.es/
Redirect 301 /try-me https://www.mitza.es/
Redirect 301 /poze-cu-elsa https://www.mitza.es/
Redirect 301 /portfolio/sea-side-store/ https://www.mitza.es/
Redirect 301 /portfolio/time-is-nothing/ https://www.mitza.es/
Redirect 301 /category/noticias https://www.mitza.es/
# BEGIN WP Performance Score Booster Settings
# END WP Performance Score Booster Settings
Redirect 301 /case-study-envato-website-redesign/ https://www.mitza.es/
# This line :
RewriteCond %{HTTP_HOST} ^www.mypage.com
You should escape spacial character like this :
RewriteCond %{HTTP_HOST} ^www\.mypage\.com
If you want to match both www or non-www replace with this :
RewriteCond %{HTTP_HOST} ^(www\.)?mypage\.com
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!