Producing SEO friendly URL in javascript

0 votes

I have a PHP function that converts a URL to an SEO friendly URL:

function seo_url($input){
     $input = str_replace(array("'", "-"), "", $input); //remove single quote and dash
     $input = mb_convert_case($input, MB_CASE_LOWER, "UTF-8"); //convert to lowercase
     $input = preg_replace("#[^a-zA-Z0-9]+#", "-", $input); //replace everything non an with dashes
     $input = preg_replace("#(-){2,}#", "$1", $input); //replace multiple dashes with one
     $input = trim($input, "-"); //trim dashes from beginning and end of string if any
     return $input;
}

I know it's pointless for SEO to do this to a URL in javascript, but for the sake of consistency I want URL's to appear the same in my application. Does anyone have the function handy in javascript?

Mar 5 in Digital Marketing by Kichu
• 17,220 points
43 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Digital Marketing

0 votes
0 answers

.htaccess give 404 Not Found when url in SEO-friendly URL

Im using opencart fresh install and using ...READ MORE

Mar 4 in Digital Marketing by Kichu
• 17,220 points
27 views
0 votes
0 answers

How to get Stack Overflow SEO friendly URL structure in Nuxt.js?

Stack Overflow has the following URL structure ...READ MORE

Mar 10 in Digital Marketing by Kichu
• 17,220 points
136 views
0 votes
0 answers

nginx clean url with seo friendly file names

I wish to implement the following which ...READ MORE

Mar 2 in Digital Marketing by Kichu
• 17,220 points
41 views
0 votes
0 answers

SEO Friendly URL

 SO gives link to question Like this ...READ MORE

Mar 3 in Digital Marketing by Kichu
• 17,220 points
21 views
0 votes
0 answers

Wordpress Plug-ins: How-to add custom SEO friendly URL Handles

I was wondering if its possible to ...READ MORE

Mar 5 in Digital Marketing by Kichu
• 17,220 points
37 views
0 votes
0 answers

Replacement of parameters in seo url with htaccess

My url: x.com/ara?il=istanbul&ilce=avcilar&marka=opel&model=corsa x.com/rent/istanbul-avcilar-opel-corsa In htaccess: RewriteRule ^rent/([0-9a-zA-Z-_]+)-([0-9a-zA-Z-_]+)-([0-9a-zA-Z-_]+)-([0-9a-zA-Z-_]+)$ ara.php?il=$1&ilce=$2&marka=$3&model=$4 [L,QSA] it does ...READ MORE

Mar 8 in Digital Marketing by Kichu
• 17,220 points
71 views
0 votes
1 answer

Removing all white-spaces from a string

You can use the 'str_replace_all()' function from ...READ MORE

answered May 16, 2018 in Data Analytics by Bharani
• 4,660 points
189 views
0 votes
1 answer

Presenting docket dtates inside html page by javascript

Use the Docker Engine Api:Docker Engine API ...READ MORE

answered Jun 20, 2018 in Docker by DareDev
• 6,890 points
197 views
0 votes
1 answer

Migrating proxy npm repo in nexus 3

I don't think you can achieve this ...READ MORE

answered Jun 22, 2018 in DevOps Tools by DareDev
• 6,890 points
771 views
+1 vote
1 answer

What is the difference between JavaScript and Java

This quote rightly explains that 2 totally ...READ MORE

answered Jun 29, 2018 in Java by Daisy
• 8,120 points
232 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP