Reputation: 706
I'm trying to rewrite some part of my URL, and I can't seem to get it to work.
I have tried following this Other Stackoverflow page
This is how I want to rewrite my URL
http://localhost/job/test-job/
to
http://localhost/jobs/test-job/
This is how my RewriteRule looks right now
RewriteRule ^job/(.*)$ jobs/$ [R=301,L]
Upvotes: 0
Views: 64
Reputation: 68611
I do something similar on my website. Try this:
RewriteRule ^/?job/(.*)$ /jobs/$1 [L,QSA,R=301]
Sometimes the URL comes through with a leading slash, sometimes without. The /?
handles that.
Upvotes: 2
Reputation: 5971
What about this:
RewriteEngine On
RewriteRule ^job/(.*)$ /jobs/$1 [R=301,L]
You can test it with htaccess tester.
Upvotes: 0