PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > comp.info.servers.unix > Possible to use wildcard in.htaccess?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.info.servers.unix Web servers for UNIX platforms.

Possible to use wildcard in.htaccess?

Réponse
 
LinkBack Outils de la discussion
Vieux 18/03/2005, 04h59   #1
licheng
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Possible to use wildcard in.htaccess?

In .htaccess, we can use

SetEnvIfNoCase Referer "^http://mywebsite\.com/" local_ref=1

But how can we specify *.mywebsite.com? For example,

content.mywebsite.com
web.mywebsite.com
pub.mywebsite.com
company.mywebsite.com

It seems that

SetEnvIfNoCase Referer "^http://*\.mywebsite\.com/" local_ref=1

or

SetEnvIfNoCase Referer "^http://\*\.mywebsite\.com/" local_ref=1

doesn't work.

Thanks in advance.
  Réponse avec citation
Vieux 18/03/2005, 10h25   #2
Tim
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Possible to use wildcard in.htaccess?

licheng <lichengNoSpam@pchome.com.tw> posted:

> In .htaccess, we can use
>
> SetEnvIfNoCase Referer "^http://mywebsite\.com/" local_ref=1
>
> But how can we specify *.mywebsite.com? For example,
>
> content.mywebsite.com
> web.mywebsite.com
> pub.mywebsite.com
> company.mywebsite.com


The dot is a wildcard in regex expressions, itself. You don't need the
asterisk for that sort of thing.

> It seems that
>
> SetEnvIfNoCase Referer "^http://*\.mywebsite\.com/" local_ref=1
>
> or
>
> SetEnvIfNoCase Referer "^http://\*\.mywebsite\.com/" local_ref=1
>
> doesn't work.


That's because the backslash in front of the dot escapes it so that it's
only treated as a dot rather than a wildcard, and you've started the
pattern matching before it.

Try: SetEnvIfNoCase Referer ".mywebsite\.com/" local_ref=1

NB: That's an untested example, but it means to match with a referrer in
this sort of fashion *mywebsite.com* (i.e. doesn't care what it starts with
or ends with, as long as that's in there somewhere).

--
If you insist on e-mailing me, use the reply-to address (it's real but
temporary). But please reply to the group, like you're supposed to.

This message was sent without a virus, please delete some files yourself.
  Réponse avec citation
Vieux 19/03/2005, 09h10   #3
licheng
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Possible to use wildcard in.htaccess?

On Fri, 18 Mar 2005 19:55:06 +1030, Tim <tim@mail.localhost.invalid>
wrote:

>> In .htaccess, we can use
>> SetEnvIfNoCase Referer "^http://mywebsite\.com/" local_ref=1
>> But how can we specify *.mywebsite.com? For example,
>> content.mywebsite.com
>> web.mywebsite.com
>> pub.mywebsite.com
>> company.mywebsite.com

>The dot is a wildcard in regex expressions, itself. You don't need the
>asterisk for that sort of thing.


So the correct syntax is ...?

SetEnvIfNoCase Referer "^http://.mywebsite\.com/" local_ref=1

or

SetEnvIfNoCase Referer "^http://.\.mywebsite\.com/" local_ref=1

doesn't work, neither.

Thanks in advance.

  Réponse avec citation
Vieux 20/03/2005, 07h10   #4
Tim
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Possible to use wildcard in.htaccess?

Unattributed authors wrote:

>>> In .htaccess, we can use
>>> SetEnvIfNoCase Referer "^http://mywebsite\.com/" local_ref=1
>>> But how can we specify *.mywebsite.com? For example,
>>> content.mywebsite.com
>>> web.mywebsite.com
>>> pub.mywebsite.com
>>> company.mywebsite.com


Tim <tim@mail.localhost.invalid>

>> The dot is a wildcard in regex expressions, itself. You don't need the
>> asterisk for that sort of thing.


licheng <lichengNoSpam@pchome.com.tw> posted:

> So the correct syntax is ...?


Regex ain't my forte, but I think the answer might be to use .* where you'd
use * as a DOS type of wildcard. (Dot being a wildcard for a single
character where the dot is, * being a ***quantifier*** for 0 or more of the
preceeding.)

e.g. SetEnvIfNoCase Referer ".*mywebsite\.com.*" local_ref=1

Though why still persist with starting with http://, instead of just
looking for mywebsite.com by itself? i.e.

> SetEnvIfNoCase Referer "^http://.mywebsite\.com/" local_ref=1
> SetEnvIfNoCase Referer "^http://.\.mywebsite\.com/" local_ref=1


Precluding the ^ [start with] "http://" preamble, and not insisting on a
trailing slash after the domain, might simplify things.

Looking at the mod_rewrite page of the Apache documents, you might be able
to do something like this: "^http://www|web|pub|company\.mywebsite.\com"
if you wanted more specific matching.

Just off the top of my head, I can't think of a simple way to test wildcard
referrer rules without having access to several domain names to throw at my
webserver. So this is all just theoretical.

NB: I do hope you realise that if you insist browsers have your site as
their referer that it's going to harm some people's use of it. The initial
visit to the site won't have that in the referrer, and only some clients
will provide a referrer as they browse around. And some privacy zealots
will include fake referrer data rather than leave it blank.

--
If you insist on e-mailing me, use the reply-to address (it's real but
temporary). But please reply to the group, like you're supposed to.

This message was sent without a virus, please delete some files yourself.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h55.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11020 seconds with 12 queries