【问题标题】:Rewrite url from /forum/page/ to /page/ (actual files are located within /forum/) [closed]将 url 从 /forum/page/ 重写为 /page/(实际文件位于 /forum/ 中)[关闭]
【发布时间】:2014-02-03 12:24:41
【问题描述】:

我的论坛文件位于文件夹目录中。现在我的网址是这样的

http://www.example.com/forum/fx/pagename/

但是我想知道是否可以使用 mod rewrite 以以下格式重写我的网址,同时将论坛文件保留在论坛文件夹中:

http://www.example.com/fx/pagename/

其中 x 等于一个数字

【问题讨论】:

标签: regex apache .htaccess mod-rewrite


【解决方案1】:

DocumentRoot(论坛上一级).htaccess 中有此规则:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!forum/).+)$ /forum/$1 [L,NC]

【讨论】:

    【解决方案2】:

    这就是你要找的吗?

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^f([0-9]+)/([^/]+) /forum/f$1/$2 [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-12
      • 1970-01-01
      • 2016-06-29
      • 1970-01-01
      • 2012-01-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多