Home Apache rewrite to map # based URL into proper URLs

# Apache rewrite to map # based URL into proper URLs

Blueboye
1#
Blueboye Published in 2018-02-10 16:24:44Z
 Long version (you can skip to TL;DR if you want to): I am working with a Wordpress site that was set up by someone else. The website has multiple pages where page has tabbed content which is accessible through #. For eg: www.example.com/services/category1/#tab-service1 www.example.com/services/category1/#tab-service2 www.example.com/services/category2/#tab-service1 www.example.com/services/category2/#tab-service2 www.example.com/services/category2/#tab-service3  Now, when search engines index they are indexing only www.example.com/services/category1/ and www.example.com/services/category2/. This creates a problem where we cannot have search engines point directly to the content within a given tab. What we want is for search engines to show links that takes users directly to (say) www.example.com/services/category2/#tab-service3. Now, I don't think google can index such # based content on its own. So, I am thinking of using apache rewrites to try to resolve this issue. I have access to .htaccess file only (from a config perspective). TL;DR How to redirect www.example.com/services/category1/service3/ to www.example.com/services/category1/#tab-service3 using apache redirects (I have access to .htaccess file)? This is what I am trying but it's not working: Options +FollowSymlinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/services/category1/([a-z0-9])/? [NC] RewriteRule .* /services/category1#tab-%1 [R,NE,L]  Someone also adviced to look into pushState server config to fix this. I am not sure how to use pushState. UPDATE: I have updated the rewrites to the following but it still doesn't work. It keeps showing Wordpress' 404 page  Options +FollowSymlinks -MultiViews RewriteEngine On RewriteBase /domainfolder/ RewriteCond %{REQUEST_URI} ^/services/category1/([a-z0-9]+)/?$[NC] RewriteRule ^/services/category1/([a-z0-9]+)/?$ /services/category1/#$1 [NE,R,L]  starkeen 2# starkeen Reply to 2018-02-10 17:28:17Z  Your %{REQUEST_URI} regex is wrong. The pattern ^/services/ category1/([a-z0- 9 ])/? matches /services/category1/{any 1 char of a-z or 0-9} format followed by an optional slash. So this does not match your request /services/category1/service3 but matches /services/category1/a/ . You should be using ^/services/category1/([a-z0-9]+)/?$ 
 You need to login account before you can post.
Processed in 0.370268 second(s) , Gzip On .