【问题标题】:.htaccess dynamic 301 rewrite.htaccess 动态 301 重写
【发布时间】:2016-06-23 16:48:49
【问题描述】:

如何转换 .htaccess 中的一些重写规则? 我的旧网站有以下内容:

RewriteRule ^([^/]*)\.html$ index.php?name=$1 [L]

这会将 url 重写为:domain.com/some-page.html

现在我正在对虚拟目录使用不同的重写,例如:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

这翻译成 domain.com/page/somepage/

我尝试过使用

Redirect 301 some-page.html page/somepage/

但不断收到 404 错误

【问题讨论】:

    标签: .htaccess mod-rewrite url-rewriting


    【解决方案1】:

    你可以用这个:

    RewriteEngine on
    
    RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
    RewriteRule ^ /page/$1 [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-31
      • 1970-01-01
      • 2010-09-10
      • 2015-07-01
      • 2010-12-03
      • 2018-06-02
      • 2013-12-21
      • 2015-03-04
      相关资源
      最近更新 更多