子域名作为子文件夹使用mod_rewrite请求?

时间:2014-10-12 18:41:35

标签: .htaccess mod-rewrite subdomain

我想在没有重定向的情况下使用子目录来执行子域。 我写这个:

RewriteCond %{HTTP_HOST} ^(www\.)?mysubdomain\.site\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/cities/mysubdomain/
RewriteRule ^(.*)$ /cities/mysubdomain/$1%{REQUEST_URI} [L]

它适用于mysubdomain.site.com,但目录中的所有文件都无法正常工作。例如mysubdomain.site.com/robots.txt打开site.com/robots.txt而非site.com/cities/subdomain/robots.txt我想要的

你能帮忙解释一下吗?

我当前的.htaccess是:

Options -Indexes 
ErrorDocument 404 /404.php

<IfModule mod_php5.c>
  php_flag allow_call_time_pass_reference 1
  php_flag session.use_trans_sid off
  #php_value display_errors 1
  #php_value mbstring.func_overload 2
  #php_value mbstring.internal_encoding UTF-8
</IfModule>

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On
  RewriteBase /
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 
  RewriteRule ^index\.php$ http://example.com [R=301,L] 

  # sub-domain redirect
  RewriteCond %{HTTP_HOST} ^(www\.)?sub\.example\.com$ [NC]
  RewriteCond %{REQUEST_URI} !^/cities/barnaul/ [NC]
  RewriteRule ^(.*)$ /cities/barnaul/$1 [L,QSA]
  # sub-domain redirect

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
  RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
  RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresByType image/jpeg "access plus 3 day"
  ExpiresByType image/gif "access plus 3 day"
</IfModule>

RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]

Redirect 301 /cities/sms-sending-samara.php http://sub.example.com
Redirect 301 /information/sms_directing.php http://example.com/#sms_directing
Redirect 301 /sitemap_000.xml http://example.com/sitemap.xml
Redirect 301 /information/information.php http://example.com/information/
Redirect 301 /help/%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C%201%D0%A1%20v8.2.pdf http://example.com/api/modul_1c.php
Redirect 301 /help/Модуль%201С%20v8.2.pdf http://example.com/api/modul_1c.php
Redirect 301 /api/modul.php http://example.com/api/modul_1c.php
Redirect 301 /help/HTTP.pdf http://example.com/api/prot_http.php
Redirect 301 /help/SMPP.pdf http://example.com/api/prot_smpp.php
Redirect 301 /help/SMTP.pdf http://example.com/api/prot_smtp.php
Redirect 301 /help/SOAP.pdf http://example.com/api/prot_soap.php
Redirect 301 /help/XML.pdf http://example.com/api/prot_xml.php
Redirect 301 /API/prot_http.php http://example.com/api/prot_http.php
Redirect 301 /API/prot_smpp.php http://example.com/api/prot_smpp.php
Redirect 301 /API/prot_smtp.php http://example.com/api/prot_smtp.php
Redirect 301 /API/prot_soap.php http://example.com/api/prot_soap.php
Redirect 301 /API/prot_xml.php http://example.com/api/prot_xml.php
Redirect 301 /rassilka_sms_internet.html http://example.com/rassilka_sms_cherez_internet.html
Redirect 301 /sms_rassilka_cherez_internet_01.html http://example.com/rassilka_sms_cherez_internet.html
Redirect 301 /internet_rassilka_sms.html http://example.com/rassilka_sms_cherez_internet.html
Redirect 301 /sms_uvedomlenie_2.html http://example.com/sms_uvedomlenie.html
Redirect 301 /sms_uslugi_2.html http://example.com/sms_uslugi.html
Redirect 301 /sms_rassilka_reklamy_01.html http://example.com/sms_rassilka_reklamy.html
Redirect 301 /sms_rassilka_03.html http://example.com
Redirect 301 /sms_rassilka.html  http://example.com
Redirect 301 /rassilka_sms_02.html  http://example.com
Redirect 301 /rassilki_sms_01.html  http://example.com
Redirect 301 /sms_reklama.html  http://example.com/information/reklama.php
Redirect 301 /sms_rassilka_deshevo.html  http://example.com/rassilka_sms_deshego.html
Redirect 301 /sms_rassilka_deshevo01.html http://example.com/rassilka_sms_deshego.html
Redirect 301 /rassilka_sms_internet.html http://example.com/rassilka_sms_cherez_internet.html
Redirect 301 /programma_cmc.html http://example.com/programma_sms.html
Redirect 301 /korporativnye_sms.htm http://example.com/korporativnye_sms.html
Redirect 301 /information/sector/index.php http://example.com/reshenia/
Redirect 301 /massovaya_rassilka_sms.html  http://example.com
Redirect 301 /API/ http://example.com/api/
Redirect 301 /API http://example.com/api/
Redirect 301 /sms_trafik.htm http://example.com/smstrafik.html
Redirect 301 /sms_shluz.htm http://example.com/smsshluz.html
Redirect 301 /sms_trafik.html http://example.com/smstrafik.html
Redirect 301 /sms_shluz.html http://example.com/smsshluz.html
Redirect 301 /information/sms_reklama.php http://example.com/information/reklama.php
Redirect 301 /rassilka_ http://example.com
Redirect 301 /information/ackciya.php http://example.com/information/post_akciya.php
Redirect 301 /information/akciya.php http://example.com/information/post_akciya.php
Redirect 301 /information/sector/gov/ http://example.com/reshenia/gosstruktury/
Redirect 301 /information/sector/ http://example.com/reshenia/
Redirect 301 /information/MMS_directing.php http://example.com
Redirect 301 /information/WAP_directing.php http://example.com
Redirect 301 /information/voice_directing.php http://example.com
Redirect 301 /mobilny_marketing.html http://example.com/mobilnymarketing.html
Redirect 301 /cities/sms-sending-belgorod.php http://sub.example.com
AddDefaultCharset cp1251

0 个答案:

没有答案