I'm trying to redirect every URL that have no #
to the same, but with #
after /path/
.
Example:
This URL: https://www.example.com/path/test/test
Need redirect to this url: https://www.example.com/path/#/test/test
So I wrote this Redirect Match:
RedirectMatch permanent ^/path/(?!#)(.*)$ /path/#/$2
But it's not working.
Browser shows me this message: ERR_TOO_MANY_REDIRECTS
You can just use this rule in your site root .htaccess:
RewriteEngine On
RewriteRule ^/?(path)/(.+)$ /$1/#/$2 [L,NE,NC,R=301]
It will redirect /path/test/test
to /path/#test/test
.
There is no need to check for presence of #
in RewriteRule
because client browsers don't send any part after #
to web server anyway.
You can try this:
RedirectMatch ^/path/([^#]+)$ /path/#/$1
The captured group ([^#]+)
represents any string, minimum 1 character, that doesn't contain #
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.