简体   繁体   English

使用htaccess将旧网址重定向到相同域的新网址

[英]redirect old url to new url of same domain using htaccess

I would like to redirect https://www.example.com/page/jobseekers to https://www.example.com/jobseekers 我想将https://www.example.com/page/jobseekers重定向到https://www.example.com/jobseekers

I used 我用了

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

But its redirecting into https://www.example.com/jobseekers?page/jobseekers . 但其重定向到https://www.example.com/jobseekers?page/jobseekers

Place this rule just below RewriteEngine On line: 将此规则放在RewriteEngine On下面的下面:

RewriteEngine On

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

# other rules go below

Make sure to test in a new browser or clear browser cachhe before testing. 在测试之前,请确保在新的浏览器中进行测试或清除浏览器缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM