【问题标题】:subfolder url get parameter not working in htaccess子文件夹 url 获取参数在 htaccess 中不起作用
【发布时间】:2017-12-19 11:50:25
【问题描述】:

我有一个像 www.abc.com/service/page.php?ids=social 这样的网站。我将网站重定向到 www.abc.com/service/social。但我需要从 url.Ex:www.abc.com/social 中避开这个文件夹。

Options +FollowSymLinks -MultiViews
 RewriteEngine on
 RewriteBase /service/
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^([a-zA-Z0-9]+|)/?$ page.php?ids=$1

【问题讨论】:

    标签: php .htaccess


    【解决方案1】:

    从正则表达式匹配中简单地排除“服务”:

    RewriteRule ^service/([a-zA-Z0-9]+|)/?$ page.php?ids=$1
    

    【讨论】:

      【解决方案2】:

      将此代码放在站点根目录 .htaccess 中(即/service/ 的父目录):

      RewriteEngine on
      RewriteBase /
      
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule !^service/ service%{REQUEST_URI} [L,NC]
      

      【讨论】:

      • 它没有重定向。
      • 它不应该重定向,它只是重写。当您在浏览器中输入www.abc.com/social 时,此 .htaccess 位于何处?是什么错误?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-30
      • 2014-04-11
      • 1970-01-01
      • 2021-04-18
      • 2023-03-08
      • 1970-01-01
      • 2012-09-07
      相关资源
      最近更新 更多