Как у меня может быть условное выражение .htaccess блок?

Я действительно думаю, что это должно быть сделано с помощью функции в JavaScript. Предполагая, что у вас есть объект с этим отображением под названием ADMIN, вы можете сделать это следующим образом.

<span [ngClass]="(role === 'ADMIN') ? 'badge badge-danger' : 'badge badge-success'">{{ this.ADMIN.USER.ROLES[role] ? 'ADMIN.USER.ROLES.' + role : 'ADMIN.USER.ROLES.unknown' | translate }}</span>
16
задан 10 April 2009 в 03:35
поделиться

3 ответа

Вместо использования SetEnv используйте возможности установки переменных среды самого RewriteRule:

RewriteCond %{HTTP_HOST} =foo.com
RewriteRule ^ - [E=VARNAME:foo]

RewriteCond %{HTTP_HOST} =bar.com
RewriteRule ^ - [E=VARNAME:bar]

Хотя я предпочитаю делать этот вид , передавая флаги процессу httpd при запуске и ища их с помощью блоков IfDefine.

<IfDefine FOO>
SetEnv VARNAME foo
</IfDefine>

<IfDefine BAR>
SetEnv VARNAME bar
</IfDefine>
15
ответ дан 30 November 2019 в 22:02
поделиться

Вот простой пример, который может быть достаточным для его изменения в соответствии с вашими требованиями:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /

    RewriteCond %{HTTP_HOST} !^localhost
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
1
ответ дан 30 November 2019 в 22:02
поделиться

On Ubuntu Linux, the IfDefine's variable is set in

/etc/apache2/envvars

and is called APACHE_ARGUMENTS. So, at the bottom of that file I had to add:

export APACHE_ARGUMENTS="-D dev"

...and then bounce the server with:

/etc/init.d/apache2 stop
/etc/init.d/apache2 start

On other systems:

However, there's a Debian article on this topic that discusses this here. In that example, the file to edit is /etc/default/apache2 and the variable is called APACHE_DEFINES.

Likewise, on some systems it is a variable named OPTIONS that is set in /etc/sysconfig/httpd.

So, what you really need to do is look for the start section in your apache2ctl file. So, begin by doing a whereis apache2ctl to find where that script is, cat it out and find the start section with the apache2 directive in it, and see if the variable it passes is OPTIONS, APACHE_ARGUMENTS, APACHE_DEFINES, or something else. Then, see which file you need to edit by experimentation with either /etc/sysconfig/httpd, /etc/default/apache2, or /etc/apache2/envvars.

6
ответ дан 30 November 2019 в 22:02
поделиться
Другие вопросы по тегам:

Похожие вопросы: