0

I'll edit this post now since now I know what it is about. I want to have a pretty URL for my website with products. In my .htaccess file i need to point to www.mydomain.com/site/#?title=orange from www.mydomain.com/site/orange

I've tried all regex possible in my .htaccess file but it just does not work. I'm starting to think it is because of the angular # (hash) sign in the URL which is required for my site to work properly.

When I click a product, then my URL changes with this code:

        var url = location.href.split('#?')[0] + element;
        window.location.href = url;
        window.location.reload();   

Then there is a reload and the link is updated to the new URL parameter showing my clicked product. I just want the www.mydomain.com/site/orange to point at www.mydomain.com/site/#?title=orange (the Hash is needed)

Tsere
  • 41
  • 3
  • Google "seo-friendly urls in X" where X is the server-side language you're using. – JJJ Oct 07 '17 at 12:42
  • I don't know why Google didn't give you this question: https://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained – Machavity Oct 07 '17 at 20:34

1 Answers1

1

There are a handful of ways to do this. The concept is called "clean urls" which basically turns a url like www.exmaple.com?page=product&slug=Womens-Jackets into www.example.com/womens-jackets

You'll first need your webserver software (Apache, Nginx, etc) to handle the initial rewrite. For Apache you can use .htaccess file to handle this thorugh mod_rewrite. How to use mod_rewrite to create clean URLs

After that your server-side application needs to handle the request parameters - for example ?page=product&slug=Womens-Jackets - and use that to look up the item in the database to display the correct page/product.

John Veldboom
  • 2,049
  • 26
  • 29
  • I host my things on one.com so I have no real power over the server side. But I think I'm able to modify a .htaccess file from there. – Tsere Oct 07 '17 at 14:39