I want to do the next
subdomain.domain.com
must load www.domain.com/app/index.php?var=subdomain
subdomain.domain.com/index.php?var2=x
must load www.domain.com/app/index.php?var=subdomain&var2=x
I have the next code that load the app folder but I also want to get the name of the subdomain but I don't know how to do it.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteCond %{HTTP_HOST} ^(\w+)\.example\.com$
RewriteCond %{REQUEST_URI}:%1 !^/([^/]+)/([^:]*):\1
RewriteRule ^(.*)$ /%1/$1 [QSA]
Thanks in advance.
Here is all my .htaccess
<Files .htaccess>
deny from all
</Files>
#ModPagespeed off
# charset
AddCharset utf-8 .html
AddCharset utf-8 .js
AddCharset utf-8 .css
AddCharset utf-8 .php
# enable expirations
<IfModule mod_expires.c>
#ExpiresActive On
#ExpiresByType image/jpg "access plus 1 week"
#ExpiresByType image/jpeg "access plus 1 week"
#ExpiresByType image/gif "access plus 1 month"
#ExpiresByType image/png "access plus 1 month"
#ExpiresByType text/css "access plus 1 week"
#ExpiresByType application/pdf "access plus 1 month"
#ExpiresByType text/x-javascript "access plus 1 week"
#ExpiresByType image/x-icon "access plus 1 year"
#ExpiresDefault "access plus 1 week"
</IfModule>
<IfModule mod_deflate.c>
#AddOutputFilterByType DEFLATE text/plain
#AddOutputFilterByType DEFLATE text/html
#AddOutputFilterByType DEFLATE text/xml
#AddOutputFilterByType DEFLATE text/css
#AddOutputFilterByType DEFLATE text/js
#AddOutputFilterByType DEFLATE application/xml
#AddOutputFilterByType DEFLATE application/xhtml+xml
#AddOutputFilterByType DEFLATE application/rss+xml
#AddOutputFilterByType DEFLATE application/x-javascript
# LE INDICAMOS PARA QUE NAVEGADORES NO DEBE COMPRIMIR YA QUE PRESENTAN BUGS
#BrowserMatch ^Mozilla/4 gzip-only-text/html
#BrowserMatch ^Mozilla/4.0[678] no-gzip
#BrowserMatch bMSIE !no-gzip !gzip-only-text/html
</IfModule>
Options +FollowSymLinks
RewriteEngine on
#fuerza el acceso https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
#Wildcards del dominio
RewriteCond %{HTTP_HOST} !=www.domain.com
RewriteCond %{HTTP_HOST} ^(\w+)\.domain\.com
RewriteRule .* /app/index.php?var=%1 [QSA]
#para error personalizado
ErrorDocument 403 "No disponible"
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
AddHandler application/x-httpd-php .html .htm .shtml .js
AddType application/x-httpd-php .html .htm .js
DirectoryIndex index.php index.html
This should add
var
variable with value of subdomain: