Some how-to using Htaccess

Some how to using Htaccess:

How to protected SVN Directories with HTACCESS File
This line in the “.htaccess” file will protect all SVN directories (“.svn/”):

<IfModule mod_rewrite.c>
RewriteRule ^(.*/)?\.svn/ - [F,L]
IfModule>

The flag “F” means forbidden, and the “L” flag means the last rule to be used if this rule is used. “-” is used to not change the original request URI. ErrorDocument can also be used with the rule to display a custom error message:

<IfModule mod_rewrite.c>
RewriteRule ^(.*/)?\.svn/ - [F,L]
ErrorDocument 403 "Access Denied"
</IfModule>

How to Force HTTPS
#force https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/ [L]

How to restrict no direct access of index.php
#no direct access of index.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://%{HTTP_HOST}/ [R=301,L]

How to get all request come to Index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

How to hide file extension
RewriteCond %{REQUEST_URI} !^/(.*)(\.)
RewriteRule ^(.*)$ index.php?do=$1&%{QUERY_STRING} [NC,L]

Image 404 .htaccess
# img not found
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$
RewriteRule .* images/spacer.gif [L]

How to force all URL should be start with www.
#force www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www\.%{HTTP_HOST}/$1 [R=301,L]

How to Redirect 301 using htaccess
Redirect 301 /path/old.htm http://www.himanshoo.in/new.htm

How to hide config files to access for outside world
Example, don’t allow access to .ini files:
#no direct access of *.ini
RewriteRule ^(.*)\.ini$ http://%{HTTP_HOST}/ [R=301,L]

Category: Linux | Tags: ,

Efficient Way to handle deep paging in Solr 4.7

Efficient Way to handle deep paging in Solr 4.7

One thing Solr has never been very efficient at is a problem that people refer to as “Deep Paging”. What is the Deep Paging?

What is Deep Paging:
Imagine the following problem – we have an application that expects Solr to return the results sorted on the basis of some field or Score. Those results will be than paged in the GUI.

However, if the person using the GUI application immediately selects the tenth, twentieth, or fiftieth page of search results there is a problem – the wait time because Solr need to lot of work for it.

Continue reading

Category: Technology | Tags: ,

Rail Budget: Not a single thing for Udaipur (Mewar)

Rail Budget: Not a single thing for Udaipur (Mewar)

Udaipur Railway Station

Udaipur City

Nobody mention of Udaipur-Ahmadabad gauge conversion

Rail Ministry, which had been a highly politicized department of the Central Government for past couple of decades, presented its Indian rail budget today. It was bound to be a complex situation for the Rail Minister Sadananda gowda not only because this particular department had always been with collaborative parties and condition of Indian Railways is very poor.

Continue reading

Category: Thoughts | Tags: ,

Searching an Element in a Rotated Sorted Array

What is Rotated Sorted Array
It is nothing but a sorted array, which is twisted/rotated with some pivot element.
So if you observe rotated array then it can be classified as two sub-array that is sorted.

For example your sorted array A:
A = { 0,1,2,3,4,5,6,7,8,9 }
and your rotated sorted array look like this:
A = { 2,3,4,5,6,7,8,9,0,1 }

Now how do you find an element in the rotated array efficiently? You may assume no duplicate exists in the array.

Continue reading

Painless Vaccine is Banned

PAINLESS PENTAXIM VACCINE IS BANNED!
hello everyone,

Yesterday we  went to vaccinate our little angel against DTaP, HiB & Polio.This was her first dose of it. i was relaxed of the pain and fever she may have to suffer because of painless vaccines (PENTAXIM,invented in 1997)  available in market.

As and when we demanded for vaccinating the baby painlessly,our paediatric informed that it has been banned.Alas ! !! is what we felt at that moment but then our peadic convinced that painless vaccines were giving lesser results than the vaccines with pains and its always better to stay safe for life than handling a little pain for that particular time.

let’s get down for the details:-
Continue reading