子域和HTACCESS无法正常工作

时间:2017-10-07 08:02:19

标签: .htaccess url redirect dns subdomain

所以我们有一个php页面www.example.com,其中包含一个重定向到www.subdomain.example.com的按钮

我们面临以下子域和htaccess的问题:

  1. 当我们使用<a href ="www.subdomain.example.com">button</a>时 媒体查询和图标不起作用
  2. 当我们使用子域代码所在的<a href ="www.example.com/folder/index2">button</a>时,URL屏蔽不起作用(但媒体查询和图标完美运行)
  3. 我们配置了HTACCESS,以便.php隐藏在网址中,www.example.com/folder/index2www.subdomain.example.com隐藏
  4. 整个子域名标题也不起作用
  5. 我们在GoDaddy中进行了以下设置:

    1. subdomain - &gt; www.subdomain
    2. www.subdomain - &gt; www.example.com/folder/index2
    3. example.com - &gt; www.example.com
    4. 子域代码位于example.com/folder/

      我们正在努力了解映射是如何工作的,因为代码在没有子域的情况下工作得非常好,但在重定向URL时会出现问题。

      主索引文件         

      <html>
      
      <head>
      
          <?php
              $dir = "favicons/";
                  $files = array();
                      if ($handle = opendir($dir))
                      {
                          while (false !== ($file = readdir($handle)))
                          {
                              $files[] = $file;
                          }
                      }
                  $icon = $files[rand(2,count($files)-1)];
              echo '<LINK REL="shortcut icon" HREF="favicons/'.$icon.'">';
          ?>
              <meta charset="utf-8">
              <title>Title</title>
              <meta content="width=device-width, initial-scale=1" name="viewport">
              <link href="assets/css/main2.css" rel="stylesheet">
      </head>
      
      <body>
          <div class="center">
          <img href=""src="images/bg.jpg">
          <br>
          <br> 
      
      
          <a href="http://www.subdomain.example.com" class ="button"><button class="bt">button</button></a>
      
          </div>
                      <script src="assets/js/jquery.min.js">
                      </script>
                      <script src="assets/js/jquery.poptrox.min.js">
                      </script>
                      <script src="assets/js/skel.min.js">
                      </script>
                      <script src="assets/js/main.js">
                      </script>
      </body>
      
      </html>
      

      Index2文件位于子域指向的文件夹中

      <!DOCTYPE html>
      
      <html>
      
      <head>
      
          <?php
              $dir = "../favicons/";
                  $files = array();
                      if ($handle = opendir($dir))
                      {
                          while (false !== ($file = readdir($handle)))
                          {
                              $files[] = $file;
                          }
                      }
                  $icon = $files[rand(2,count($files)-1)];
              echo '<LINK REL="shortcut icon" HREF="../favicons/'.$icon.'">';
          ?>
              <meta charset="utf-8">
              <title>Title</title>
              <meta content="width=device-width, initial-scale=1" name="viewport">
              <link href="../assets/css/main1.css" rel="stylesheet">
              <link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
      </head>
      
      <body>
      <h1>random text</h1>
                  <br>
                      <script src="assets/js/jquery.min.js">
                      </script>
                      <script src="../assets/js/jquery.poptrox.min.js">
                      </script>
                      <script src="../assets/js/skel.min.js">
                      </script>
                      <script src="../assets/js/main.js">
                      </script>
      </body>
      
      </html>
      

      HTACCESS文件

      # Turn mod_rewrite on
      RewriteEngine On
      RewriteBase /
      
      # To externally redirect /dir/foo.php to /dir/foo/
      RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
      RewriteRule ^ %1 [R,L,NC]
      
      ## To internally redirect /dir/foo/ to /dir/foo.php
      RewriteCond %{REQUEST_FILENAME}.php -f [NC]
      RewriteRule ^ %{REQUEST_URI}.php [L]
      
      ErrorDocument 400     www.example.com/Error-404
      ErrorDocument 401     www.example.com/Error-404
      ErrorDocument 403     www.example.com/Error-404
      ErrorDocument 404     www.example.com/Error-404
      ErrorDocument 500     www.example.com/Error-404
      

0 个答案:

没有答案