skip to Main Content

I need to create friendly urls for my website

need to change this url:
http://sitename.com/pn?title=1100متر+ویلایی+گلابدره&id=117

to this url, that contains utf-8 characters to
http://sitename.com/1100متر+ویلایی+گلابدره

I also need my variables like id, by using htaccess rewriting can i stil use them ?

is there a good doc that i can learn more about url rewriting ?
and is url rewriting good for website seo ?

THANKS

2

Answers


  1. Here is your code

    var currentURL = window.location.href;
    var currentDomain = window.location.hostname;
    function getParameterByName(name, url) {
        if (!url) {
          url = window.location.href;
        }
        name = name.replace(/[[]]/g, "\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/+/g, " "));
    }
    window.history.pushState('page',document.title,getParameterByName('title'))
    Login or Signup to reply.
  2. Try it like this, I am unsure about the character you are passing and also you need to pass id in url too for rewriting. Please let me know if it works.

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/([d]+)$ pn?title=$1&id=$2 [QSA,NC,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search