Pregunta

Necesito una solución muy rápida en una expresión mod_rewrite para drupal que tenemos

  RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$ 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Pero también necesito redireccionar el valor del subdominio en get, así que necesito algo que me dé:

  RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$ 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?subdomain=THE SUBDOMAIN HERE&q=$1 [L,QSA]

No sé cómo hacerlo, por favor, ayuda!

¿Fue útil?

Solución

Intentando esto de nuevo, por alguna razón, mi código no se está mostrando correctamente.

RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$
RewriteRule ^(.*) index.php?subdomain=%1&q=1 [L,QSA]

Basado en algunas publicaciones del foro, encontré aquí .

Otros consejos

Realmente no necesitas el subdominio en la cadena de consulta.

El subdominio se puede encontrar en PHP en $ _SERVER ['SERVER_NAME'].

documentación de PHP dice:

'SERVER_NAME'
    The name of the server host under which the
    current script is executing. If the script
    is running on a virtual host, this will be
    the value defined for that virtual host. 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top