I am looking to extract specific portions of a URL and here is my progress so far.
<script type='text/javascript'>
var query = window.location.pathname.split( '/' );
query = window.location.pathname.split( '.html' );
var redirectpath = "http://www.mydomain.com/search/?q="
window.location.href = redirectpath + query;
</script>
URL structure example:
http://www.mydomain.com/page/2013/05/some-page-title.html
The query
variable outputs as follows:
page,2013,05,some-page-title
I am interested in only the some-page-title
part and would like to remove any hyphens.
Therefore, the final output should be
http://www.mydomain.com/search/?q=some page title
Any suggestions on achieving this? Your help would be greatly appreciated! Thank you