2015-06-11 1 views
0

Я хочу сделать следующийПерепишите подстановочные субдомна в ту же папку имени и получить имя поддомена

subdomain.domain.com необходимо загрузить www.domain.com/app/index.php?var=subdomain subdomain.domain.com/index.php?var2=x необходимо загрузить www.domain.com/app/index.php?var=subdomain&var2=x

У меня есть следующий код, который загружается в папке приложения, но Я также хочу получить имя субдомена, но я не знаю, как это сделать.

RewriteEngine on 
RewriteCond %{HTTP_HOST} !^www\.example\.com$ 
RewriteCond %{HTTP_HOST} ^(\w+)\.example\.com$ 
RewriteCond %{REQUEST_URI}:%1 !^/([^/]+)/([^:]*):\1 
RewriteRule ^(.*)$ /%1/$1 [QSA] 

Заранее спасибо.

Вот все мои .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 

ответ

1

Это должно добавить var переменные со значением подобласти:

RewriteEngine on 
RewriteCond %{HTTP_HOST} !=www.example.com 
RewriteCond %{HTTP_HOST} ^(\w+)\.example\.com 
RewriteRule .* /add/index.php?var=%1 [QSA] 
+0

Привет, я попытался с помощью кода, и я получаю внутреннюю ошибку сервера. – chelssi

+0

Я проверил, и это сработало для меня. * «Внутренняя ошибка сервера» * обычно означает синтаксическую ошибку в '.htaccess'. Покажите свой полный файл. – umka

+0

Привет, @umka, я добавил к вопросу весь мой .htaccess – chelssi

 Смежные вопросы

  • Нет связанных вопросов^_^