简体   繁体   中英

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

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 .

Place this rule just below RewriteEngine On line:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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