Making RewriteRule portable/relative to the directory of the .htaccess file
snippet in htaccess

Making RewriteRule portable/relative to the directory of the .htaccess file

user4160

RewriteEngine On

RewriteCond $0#%{REQUEST_URI} ^([^#]*)#(.*)\1$
RewriteRule ^.*$ - [E=BASE:%2]

RewriteCond %{THE_REQUEST} \?page=(\d+) [NC]
RewriteRule ^ %{ENV:BASE}/%1/? [R=301,L]