Removing part of a URL using mod_rewrite


I am trying to remove part of a URL using mod_rewrite, but what I have isn’t working.

I have the following URL:

(the /phase-2/ is temporary as this is a development stage so it will be switched to not using that part)

I’m trying to remove the /job/ part of the URL.

This is what I have:

RewriteEngine ON
RewriteRule ^job/(.*)$ $1 [L,QSA]

Can anyone tell me what I have wrong?


As long as phase-2 is in the URL that RewriteRule is never going to match, you’d need to include it:

RewriteEngine On
RewriteRule ^phase-2/job/(.*) /phase-2/$1 [L,QSA]

Did you want to redirect the browser by the way, or leave the URL in the browser as is?


Thanks for the reply. I think ideally it would redirect them.

Ok, in that case you should replace [L,QSA] with [L,QSA,R=301]

1 Like

Many thanks for your help :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.