douwen7905 2017-03-30 18:19
浏览 41

使用htaccess重定向子域

I am trying to set up a subdomain so that it will redirect to a specific file. EG. register.mydomain.com should show the page at www.mydomain.com/includes/register.php but still show register.mydomain.com in the browser.

The site is currently set up to not show extensions in the address bar eg. www.mydomain.com/register using the htaccess file as below and this works fine.

RewriteEngine On
RewriteRule ^register$ includes/register.php
  • 写回答

1条回答 默认 最新

  • 普通网友 2017-03-31 00:28
    关注

    The first thing to notice here, is the files should be in same document root. This means, your .htaccess file and includes/register.php files should be in same root folder for application. You can then rewrite the rule -

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^register\.mydomain\.com$ [NC]
    RewriteRule ^$ includes/register.php [L]
    

    This might work, reload Apache after changing .htaccess files.

    评论

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应