0

I have this below URL and all # symbols needs to replaced with _

http://localhost/test/my#module/my#index.php?param2=10&param2=10

i tried below .htaccess code, but not working. I searched a lot for solution , but none of them are working.

Options +FollowSymlinks -MultiViews
RewriteEngine on
# keep replacing space to hyphen until there is no space use internal rewrite
RewriteRule ^([#]*)[#]+(.*)$ $1-$2 [E=NOSPACE:1]
# when there is no space make an external redirection
RewriteCond %{ENV:NOSPACE} =1
RewriteRule ^([#]+)$ $1 [R=301,L]

Please let me how can fix this issue.

5
  • 2
    # and part after that is not sent to web server Commented Aug 12, 2016 at 9:45
  • @anubhava, sorry i did not get you . You mean to to day that # and part after that will be ignored. Actually i tried your answer stackoverflow.com/questions/5821120/… , but not working for me. Commented Aug 12, 2016 at 10:08
  • 1
    That answer is not for #. Browser doesn't send any text starting with # to web server. Commented Aug 12, 2016 at 10:10
  • I mean to say that i tried the same examples with space not with #. My issue is that we are sending URLs via SMS to user . If the urls have _ then they are getting replaced by space there by breaking URLs in SMS. So we need alternative to _ in the url. So once the user hits that URLs then using htaccess we planning to replace alternate character with _. We can not use & and % . Can you please suggest on this ?? Commented Aug 12, 2016 at 10:15
  • I suggest you update the question with these requirements. And clarify what is original URL and what is redirected one you desire to be. Commented Aug 12, 2016 at 10:43

0

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.