views:

128

answers:

3

As you know the dash introduces a comment

how can I make this valid?

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.php$ /#$1 [R=301,NC]
+1  A: 

Use the NE flag:

RewriteRule ^(.+)\.php$ /#$1 [R=301,NE]

By the way: The # is only the start of a comment if used at the start of a line:

Lines that begin with the hash character "#" are considered comments, and are ignored. Comments may not be included on a line after a configuration directive.

Gumbo
A: 

Replace the # with \%23, and that should do the trick, or use the [NE]/noescape flag.

John Feminella
+1  A: 

You can't manager data after # by apache. Even facebook handles redirection for data after # by javascript.

If I'm wrong, please someone correct me, some years ago this problem drives me crazy.

Enrico Carlesso
You can’t read the fragment of a URI on the server side as it’s not sent to the server but just used locally. But the server can response with a redirect with a URI with fragment.
Gumbo
Thanks for the clarification. It's like I've found out some times ago.
Enrico Carlesso