【问题标题】:subdomains with only .htaccess只有 .htaccess 的子域
【发布时间】:2013-09-26 10:44:06
【问题描述】:

我得到了 url 链接区域 ex。 http://mysite.it/index.php?page=search&sRegion=Toscana

可以使用 htaccess 制作像 toscana.mysite.it 这样的 url 谢谢解答

这是我的 htaccess:

<IfModule mod_rewrite.c> 
Options +FollowSymLinks -MultiViews
RewriteEngine On 
RewriteBase /

RewriteCond %{HTTP_HOST} ^mysite\.it$ [NC] 
RewriteCond %{QUERY_STRING} (^|&)sRegion=([^&]*) [NC] 
RewriteRule ^index\.php$ http://%2.%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

【问题讨论】:

标签: .htaccess subdomain


【解决方案1】:

通过httpd.conf 启用mod_rewrite.htaccess,然后将此代码放入您的DOCUMENT_ROOT/.htaccess 文件中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^mysite\.it$ [NC]
RewriteCond %{QUERY_STRING} (^|&)sRegion=([^&]+) [NC]
RewriteRule ^index\.php$ http://%2.%{HTTP_HOST}%{REQUEST_URI} [R=302,NC,L]

【讨论】:

  • 抱歉,我的回答有误。修复它,现在尝试编辑代码。
  • 我试过了,可以,但是我重定向到mysite.it,所以dns没问题,但是查询没有执行,缺少什么?
  • 感谢 anubhava 的回答,重写工作,我得到了 sRegion.mysite.it/index.php?page=search&sRegion=Toscana,但我收到此错误“网页有重定向循环”和空白页。我的 htaccess: 选项 +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^ohpla\.it$ [NC] RewriteCond %{QUERY_STRING} (^|&)sRegion=([^&]* ) [NC] RewriteRule ^index\.php$ http://%2.%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME } !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule 。 /index.php [L]
  • 希望你能帮帮我,我真的需要,我从四面八方敲我的头
  • 我无法从 cmets 读取您的代码,请通过编辑您的问题发布此代码。
猜你喜欢
  • 2015-06-03
  • 1970-01-01
  • 2016-10-19
  • 2015-07-12
  • 1970-01-01
  • 2011-09-21
  • 1970-01-01
相关资源
最近更新 更多