【问题标题】:htaccess RewriteRule and RewriteBasehtaccess RewriteRule 和 RewriteBase
【发布时间】:2018-02-07 08:03:31
【问题描述】:

我想隐藏部分网址 当前网址: https://dev.karmagroup.com/karmamomentsnew/karma-postcards/

我的目标是 https://dev.karmagroup.com/karma-postcards/

使用当前的 .htaccess 文件:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /karmamomentsnew/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /karmamomentsnew/index.php [L]
</IfModule>

我试图像这样更改 .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /karmamomentsnew/(.+)$ $1 [L,NC,R]
</IfModule>

而且肯定会出错,哈哈.. 有人可以帮帮我吗。之前谢谢你。

【问题讨论】:

    标签: regex .htaccess regex-lookarounds


    【解决方案1】:

    我发现这个相关的问题可以回答您的问题。答案中的 sn-p 是(请注意,它已根据您的需要进行调整)

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule (?!^karmamomentsnew/)^(.*)$ /karmamomentsnew/$1 [L,NC]
    

    来源:https://stackoverflow.com/a/18361995/5675325

    【讨论】:

      猜你喜欢
      • 2011-01-09
      • 2023-03-03
      • 2013-05-17
      • 2013-08-27
      • 2020-06-21
      • 2012-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多