logo
down
shadow

.htaccess cascading conditions


.htaccess cascading conditions

By : user2949189
Date : November 16 2020, 06:23 AM
Hope this helps I'm trying to figure out how to manage potentially conflicting conditions in .htaccess , You can rearrange your conditions logic.
code :
# if www.myCMSdomain.com or myCMSdomain.com -> do nothing
RewriteCond %{HTTP_HOST} ^(?:www\.)?myCMSdomain\.com$ [NC]
RewriteRule ^ - [L]

# if we reach here, this means it's a subdomain/another domain

# images rule
RewriteRule ^images-([^/]+)/(.+)$ /admin/site/$1/images/$2 [L]

# not a file/directory -> sites/index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /sites/index.php [L]


Share : facebook icon twitter icon
how to prevent htaccess directive from cascading to subdirectories

how to prevent htaccess directive from cascading to subdirectories


By : user6792730
Date : March 29 2020, 07:55 AM
will help you Basically you create a new .htaccess file in your sub directory to override the root one. There are more details regarding this described in this question:
How to remove .htaccess password protection from a subdirectory
Conditionally selecting top 1 from groups based on cascading conditions

Conditionally selecting top 1 from groups based on cascading conditions


By : John Dennehy
Date : March 29 2020, 07:55 AM
seems to work fine Your question is just saying: "Use row_number(), Use row_number()!"
This assigns a sequential number to each row within a group. The rows are ordered based on the order by. For this, just use the logic for your priorities:
code :
select Id, MovieId, FormatId, SourceId, Date, Lock, Created, Modified
from (select t.*,
             row_number() over (partition by MovieId, FormatId, Date
                                order by (case when SourceId = 1 AND Lock NOT NULL then 1
                                               when SourceId = 4 then 2
                                               when SourceId <> 2 then 3
                                               when SourceId = 2 then 4
                                               else 5
                                          end), Modified desc
                               ) as seqnum,
            sum(case when SourceId = 2 then 1 else 0 end) over (partition by MovieId, FormatId, Date) as NumSourceId2
      from table t
     ) t
where seqnum = 1 and not (SourceId = 2 and NumSourceId2 > 1);
error in installing Github Project Cascading/vagrant-cascading-hadoop-cluster

error in installing Github Project Cascading/vagrant-cascading-hadoop-cluster


By : Akihisa Urushibara
Date : March 29 2020, 07:55 AM
Any of those help Normally a timeout implies the file took too long to download from the server. You'll need to add a timeout => 0 to that command, or a high enough value. Puppet's default timeout for exec is 300 seconds.
However, since it's downloading a quite small shell script there might be a networking issue with that URL it wgets. It's possible you were rate-limited or Github took long to respond when it tried to run that command.
code :
vagrant ssh
wget --no-check-certificate http://raw.github.com/fs111/grrrr/master/grrr -O /tmp/grrr && chmod +x /tmp/grrr
exit
vagrant --provision
Django, cascading move to a separate table instead of cascading delete

Django, cascading move to a separate table instead of cascading delete


By : Alex D.
Date : March 29 2020, 07:55 AM
I wish this help you I'd like to keep data when we delete , I implemented this myself and I'm sharing my findings.
Archive
code :
 class DeleteModelQuerySet(object):
     '''
     take a look at django.db.models.deletion
     '''

     def hard_delete(self):
         super().delete()

     def delete(self):
         if not self.is_archivable():
             super().delete()
             return

         archive_object_ids = []
         seen = []

         collector = NestedObjects(using='default')  # or specific database
         collector.collect(list(self))
         collector.sort()

         with transaction.atomic():

             for model, instances in six.iteritems(collector.data):

                 if model in self.model.exclude_models_from_archive():
                     continue

                 assert hasattr(model, "is_archivable"), {
                     "model {} doesn't know about archive".format(model)
                 }

                 if not model.is_archivable():
                     # just delete
                     continue

                 for instance in instances:

                     if instance in seen:
                         continue
                     seen.append(instance)

                     for ptr in six.itervalues(instance._meta.parents):
                         # add parents to seen
                         if ptr:
                             seen.append(getattr(instance, ptr.name))

                     archive_object = model.create_archive_object(instance)
                     archive_object_ids.append(archive_object.id)

             # real delete
             super().delete()

         archive_objects = self.model.get_archive_model().objects.filter(id__in=archive_object_ids)
         return archive_objects

     def undelete(self):

         with transaction.atomic():
             self.unarchive()

             super().delete()

     def is_archivable(self):
         # if false, we hard delete instead of archive
         return self.model.is_archivable()

     def unarchive(self):

         for obj_archive in self:
             self.model.create_live_object(obj_archive)


 class DeleteModelMixin(models.Model):

     @classmethod
     def is_archivable(cls):
         # override if you don't want to archive and just delete
         return True

     def get_deletable_objects(self):
         collector = NestedObjects(using='default')  # or specific database
         collector.collect(list(self))
         collector.sort()
         deletable_data = collector.data

         return deletable_data

     @classmethod
     def create_archive_object(cls, obj):
         # http://stackoverflow.com/q/21925671/433570
         # d = cls.objects.filter(id=obj.id).values()[0]

         d = obj.__dict__.copy()
         remove_fields = []
         for field_name, value in six.iteritems(d):
             try:
                 obj._meta.get_field(field_name)
             except FieldDoesNotExist:
                 remove_fields.append(field_name)
         for remove_field in remove_fields:
             d.pop(remove_field)

         cls.convert_to_archive_dictionary(d)

         # print(d)

         archive_object = cls.get_archive_model().objects.create(**d)
         return archive_object

     @classmethod
     def create_live_object(cls, obj):

         # index error, dont know why..
         # d = cls.objects.filter(id=obj.id).values()[0]

         d = obj.__dict__.copy()

         remove_fields = [cls.convert_to_archive_field_name(field_name) + '_id' for field_name in cls.get_twostep_field_names()]
         for field_name, value in six.iteritems(d):
             try:
                 obj._meta.get_field(field_name)
             except FieldDoesNotExist:
                 remove_fields.append(field_name)

         for remove_field in remove_fields:
             d.pop(remove_field)

         cls.convert_to_live_dictionary(d)

         live_object = cls.get_live_model().objects.create(**d)
         return live_object

     @classmethod
     def get_archive_model_name(cls):
         return '{}Archive'.format(cls._meta.model_name)

     @classmethod
     def get_live_model_name(cls):

         if cls._meta.model_name.endswith("archive"):
             length = len("Archive")
             return cls._meta.model_name[:-length]
         return cls._meta.model_name

     @classmethod
     def get_archive_model(cls):
         # http://stackoverflow.com/a/26126935/433570
         return apps.get_model(app_label=cls._meta.app_label, model_name=cls.get_archive_model_name())

     @classmethod
     def get_live_model(cls):
         return apps.get_model(app_label=cls._meta.app_label, model_name=cls.get_live_model_name())

     @classmethod
     def is_archive_model(cls):
         if cls._meta.model_name.endswith("Archive"):
             return True
         return False

     @classmethod
     def is_live_model(cls):
         if cls.is_archive_model():
             return False
         return True

     def make_referers_point_to_archive(self, archive_object, seen):

         instance = self

         for related in get_candidate_relations_to_delete(instance._meta):
             accessor_name = related.get_accessor_name()

             if accessor_name.endswith('+') or accessor_name.lower().endswith("archive"):
                 continue

             referers = None

             if related.one_to_one:
                 referer = getattr(instance, accessor_name, None)
                 if referer:
                     referers = type(referer).objects.filter(id=referer.id)
             else:
                 referers = getattr(instance, accessor_name).all()

             refering_field_name = '{}_archive'.format(related.field.name)

             if referers:
                 assert hasattr(referers, 'is_archivable'), {
                     "referers is not archivable: {referer_cls}".format(
                         referer_cls=referers.model
                     )
                 }

                 archive_referers = referers.delete(seen=seen)
                 if referers.is_archivable():
                     archive_referers.update(**{refering_field_name: archive_object})

     def hard_delete(self):
         super().delete()

     def delete(self, *args, **kwargs):
         self._meta.model.objects.filter(id=self.id).delete()

     def undelete(self, commit=True):
         self._meta.model.objects.filter(id=self.id).undelete()

     def unarchive(self, commit=True):
         self._meta.model.objects.filter(id=self.id).unarchive()

     @classmethod
     def get_archive_field_names(cls):
         raise NotImplementedError('get_archive_field_names() must be implemented')

     @classmethod
     def convert_to_archive_dictionary(cls, d):

         field_names = cls.get_archive_field_names()
         for field_name in field_names:
             field_name = '{}_id'.format(field_name)
             archive_field_name = cls.convert_to_archive_field_name(field_name)
             d[archive_field_name] = d.pop(field_name)

     @classmethod
     def convert_to_live_dictionary(cls, d):

         field_names = list(set(cls.get_archive_field_names()) - set(cls.get_twostep_field_names()))

         for field_name in field_names:
             field_name = '{}_id'.format(field_name)
             archive_field_name = cls.convert_to_archive_field_name(field_name)
             d[field_name] = d.pop(archive_field_name)

     @classmethod
     def convert_to_archive_field_name(cls, field_name):
         if field_name.endswith('_id'):
             length = len('_id')
             return '{}_archive_id'.format(field_name[:-length])
         return '{}_archive'.format(field_name)

     @classmethod
     def convert_to_live_field_name(cls, field_name):
         if field_name.endswith('_archive_id'):
             length = len('_archive_id')
             return '{}_id'.format(field_name[:-length])
         if field_name.endswith('archive'):
             length = len('_archive')
             return '{}'.format(field_name[:-length])
         return None

     @classmethod
     def get_twostep_field_names(cls):
         return []

     @classmethod
     def exclude_models_from_archive(cls):
         # excluded model can be deleted if referencing to me
         # or just lives if I reference him
         return []

     class Meta:
         abstract = True
How to prevent .htaccess redirect rules from cascading to sites held in sub-directories of the 'public_html' root?

How to prevent .htaccess redirect rules from cascading to sites held in sub-directories of the 'public_html' root?


By : 김형석
Date : March 29 2020, 07:55 AM
Any of those help Basically, I have some sub-directories in the root of the 'public_html' directory (of an Apache server) where I keep my main website ( http://www.jamesandersonjr.com ). The main website files are directly in the 'public_html' root directory, whereas other sites (with their own separate domains), are in sub-folders/sub-directories under the root. , You could try wrapping your rules with this:
code :
<If "%{HTTP_HOST} == 'www.jamesandersonjr.com'">
    ...
</If>
<If "%{HTTP_HOST} =~ /(?:^|\.)jamesandersonjr\.com$/">
    ...
</If>
<If "%{HTTP_HOST} =~ /\.jamesandersonjr\.com$/">
    ...
</If>
Related Posts Related Posts :
  • How to root multiple domains to multiple subfolders
  • .htaccess not working on localhost
  • .htaccess url rewrite GET parameter and remove .php without breaking javascript/css
  • .htaccess redirect non-WWW to WWW
  • Use same variable name in htaccess for rewriting PHP page
  • ERROR: CCurlFile::FillBuffer - Failed: HTTP response code said error(22) xbmc
  • Rewrite URL empty values in query string - Double slashes, Optional Parameters
  • RewriteRule for htaccess note working
  • how to use mod_rewrite on a file in a folder?
  • How to rewrite then redirect the old URL to the rewrited URL
  • htaccess rewrite all urls with a certain query to a parent directory
  • Forcing SSL only on the main domain on cPanel
  • How to create clean url using .htaccess for multiple parameters
  • How to redirect all urls within a directory to a hashed version of the same url?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org