【问题标题】:redirect old url to new url of same domain using htaccess使用 htaccess 将旧 url 重定向到同一域的新 url
【发布时间】:2018-06-22 12:58:08
【问题描述】:

我想将https://www.example.com/page/jobseekers 重定向到https://www.example.com/jobseekers

我用过

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

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

Redirect /page/jobseekers /jobseekers

但它重定向到https://www.example.com/jobseekers?page/jobseekers

【问题讨论】:

  • @anubhava 没有发生同样的事情。

标签: .htaccess url redirect


【解决方案1】:

将此规则放在RewriteEngine On 行的下方:

RewriteEngine On

RewriteRule ^page/(jobseekers)/?$ /$1? [L,NC,R=301]

# other rules go below

确保在测试前在新浏览器中测试或清除浏览器缓存。

【讨论】:

  • 我想将所有在 URL 中有商店的页面重定向到没有商店 URL 的页面,例如:example.com/shop/my-info 重定向到 example.com/my-info 请帮助我为此制定规则。
  • @PurushotamSharma:使用RewriteRule ^shop/(.*)$ /$1 [L,NC,R=301]
猜你喜欢
  • 1970-01-01
  • 2015-07-17
  • 2015-09-14
  • 2022-06-11
  • 2017-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-16
相关资源
最近更新 更多