【问题标题】:htaccess and Mod_rewrite in subdomains子域中的 htaccess 和 Mod_rewrite
【发布时间】:2015-07-22 23:37:38
【问题描述】:

在我的 htaccess 中,我将其设置为重写 URL,因此查询字符串实际上不会显示(漂亮的 url),但似乎如果该站点被放置在子域中,它会显示一个空白页面,副转到正确的页。子域会影响其工作方式还是另一个问题?

RewriteEngine On
RewriteRule ^documents/([^/]+)/?$ documents.php?p=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

将文件夹/documents.php?p=value 转换为 www.mywebsite.com/folder/documents/VARIABLE(删除 .php?p=value)

子域等价物: subdomain.mywebsite.com/folder/documents/VARIABLE

【问题讨论】:

    标签: .htaccess mod-rewrite subdomain


    【解决方案1】:

    尝试使用以下代码关闭MultiViews 选项:

    Options -MultiViews
    RewriteEngine On
    
    RewriteRule ^documents/([^/]+)/?$ documents.php?p=$1 [L,QSA,NC]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php [L]
    

    选项 MultiViews 由运行 before mod_rewriteApache's content negotiation module 使用,并使 Apache 服务器匹配文件的扩展名。所以/file 可以在 URL 中,但它会服务于/file.php

    【讨论】:

      猜你喜欢
      • 2012-03-25
      • 2013-08-04
      • 1970-01-01
      • 2013-07-14
      • 2016-07-06
      • 1970-01-01
      • 2013-12-02
      • 2012-04-01
      • 1970-01-01
      相关资源
      最近更新 更多