I want to customize the structure of my wordpress permalinks slightly beyond what’s offered by default. I want to add #/ before the /%postname%/, so that instead of current permalinks:
http://www.mybusinesssite.com/about/thecompany
I get this:
http://www.mybusinesssite.com/#/about/thecompany
EDIT: Here’s what’s not working: The actual permalink for the page is http://www. mybusinesssite.com/about/thecompany
â but when I load that page into the main index page, the url display changes to http://www. mybusinesssite.com/#/about/thecompany
. The page displays just fine, but it can’t be properly bookmarked, because accessing http://www. mybusinesssite.com/#/about/thecompany
via bookmark leads the user to the initial state of the page, rather than the page with the content loaded from /about/thecompany. What I want to do is have the actual page permalink as #/about/thecompany
. Then I will split that url in segments with JavaScript, remove the initial #/
segment, and add everything else after the JavaScript hash. As a result, I will have #/about/thecompany
in he url, which will be the actual url of that page.
How can this be done?
As properly explained here, you can not read anything past the hash via PHP because it is not transmitted to the server at all.
You could have a script on your first page that gets the subpage via ajax but that would be a mess for search engines and general usability.
As stated in the comments above: the URL part after
#
is not passed to the server – as in, only the user browser knows about it. If the user bookmarks: a link with the hash char – when acessing that, the only parth that will leave the users’ device ishttp://www.example.com/
– so, even if you acomplish customizing your wordpress URL’s as you want, it would no work (it could work for any other character, but for#
)To resolve your problem there you will need a solution in javascript on your portal root – it can even turn to be a simple one. (reading the original URL, which javascript being on the client side, include the chars past the
#
, and loading it from the server, removing the#
)