2

I'm trying to redirect http://terrychew.com.sg/classes to http://terrychew.com.sg/math-olympiad-singapore#Primary because without the #Primary, the tab I want users to see will not be selected.

.htaccess converts my # into %23 which doesn't work for me. I read on another thread that this code can be used to redirect with hashtags in the url

if (window.location.hash == "#/de/about/blog/") {
    window.location = 'http://google.com.ua';
    }

however, in this case, the OLD url contains the hashtag. I need code that works when the NEW url contains the hashtag. I tried reversing the code but it does not work

2
  • RewriteCond %{HTTP_HOST} ^terrychew\.com\.sg$ [OR] RewriteCond %{HTTP_HOST} ^www\.terrychew\.com\.sg$ RewriteRule ^classes\.html$ "http\:\/\/terrychew\.com\.sg\/math\-olympiad\-singapore" [R=301,L] Commented May 7, 2016 at 17:17
  • this code was generated in .htaccess by my server. i used cPanel to perform a 301 redirect. However, if I add a # in the NEW url, it appears as %23 in my browser which is useless! Commented May 7, 2016 at 17:19

1 Answer 1

4

You are probably not using the NE flag.

By default, special characters, such as & and ?, for example, will be converted to their hexcode equivalent. Using the [NE] flag prevents that from happening.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.