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, 2022 in Digital Marketing by Kichu
• 19,040 points
642 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, 2022 in Digital Marketing by Kichu
• 19,040 points
1,143 views
0 votes
1 answer

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

The following worked for me : To get ...READ MORE

answered Mar 11, 2022 in Digital Marketing by narikkadan
• 63,600 points
1,793 views
0 votes
0 answers

nginx clean url with seo friendly file names

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

Mar 2, 2022 in Digital Marketing by Kichu
• 19,040 points
724 views
0 votes
0 answers

SEO Friendly URL

 I'm creating a blog where i want ...READ MORE

Mar 3, 2022 in Digital Marketing by Kichu
• 19,040 points
365 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, 2022 in Digital Marketing by Kichu
• 19,040 points
623 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, 2022 in Digital Marketing by Kichu
• 19,040 points
1,307 views
0 votes
0 answers

How can I validate an email address in JavaScript?

To avoid the most basic mistyping, I'd ...READ MORE

Sep 20, 2022 in Java by Nicholas
• 7,760 points
439 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
616 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
733 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
1,520 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP