user2439124
user2439124

Reputation: 291

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.

Upvotes: 0

Views: 90

Answers (1)

anubhava
anubhava

Reputation: 786091

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.

Upvotes: 1

Related Questions