If by "escape", you mean "remove" (as in your example) then you can do something like the following in your Apache config (or .htaccess
) file:
RedirectMatch 301 ^(?!/site_url/course/).+/([^/.]+)$ /site_url/course/$1
The negative lookahead (ie. (?!/site_url/course/)
) ensures that the redirected request is not also redirected (which would cause a redirect-loop).
This is assuming you are not already using mod_rewrite.
And this obviously doesn't do anything to capitalise any letters, since your example appears to go from /coursename
to /courseName
, which is not a discernable pattern (unless this is literal text?!).
Test with a 302 (temporary) redirect to avoid potential caching issues.