Evanss
Evanss

Reputation: 23593

Add # character to url address with htaccess file?

With an htaccess file can I alter the destination of incoming links to add a # character?

If someone navigates to mysite.com/page2 I need them to be directed to mysite.com/#page2.

Upvotes: 1

Views: 401

Answers (1)

anubhava
anubhava

Reputation: 785156

put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /#$1 [L,NE,R]

Upvotes: 1

Related Questions