404 error when using # in url in rewrites

Yes, I know that the # sign is reserved.

These are used for named identifiers, ie xxx.html#gohere . These #'s, of course, are reserved, but is there a way to use them?

I have tried to use %23 instead of the # sign in some url rewrites, but they all return 404 errors. I tried quotes also, but to no avail?

Is there a way to use #'s in the url’s anyway?

:confused:

Good to know, I had the same issue a while back so I had a feeling that it might have been what you were looking for :slight_smile:

Thanks Alex.

I am using the NoEscape (NE) flag & all is working correctly.
:slight_smile:

Jeez dude!

I am not doing this in the .htaccess file, I am using a redirects.conf file in the Apache content area, so I do not need to terminate each statement.
:injured:

Alex,

That’s for the redirection. I believe that the OP was talking about preserving a page anchor. Thanks for that reminder, though (but don’t forget the Last flag!).

Regards,

DK

eh,

What else is in your .htaccess that could be impacting this?

Alex is correct, though, as adding the page anchor needs the NoEscape (NE) flag.

The L flag that terminates a mod_rewrite (block) statement just like ; or } in JavaScript and PHP. PHP doesn’t work without them, JavaScript is dicey but mod_rewrite will believe that the omission is intentional and will AND successive (block) statements until it receives the Last flag. In other words, learn to code correctly. :injured:

Regards,

DK

Ah, I was under the assumption he was trying to invoke a redirect while ensuring the hash character wasn’t filtered (I guess the OP will have to let us know!) :slight_smile:

I guess there is NO way to use the rewrites to redirect with a named anchor in it?

Evans Craig

Actually there is a pretty simple way to allow for the use of hash characters within a URL structure, all you need to-do is add a no-escape to your mod rewrites.

As an example:

RewriteRule ^before.html$ /before.html#after [R,NE]

PS: Patience is a virtue, we don’t get paid to help people so don’t expect immediate answers.

What last flag?

I am trying to just use regular redirects with existing ones (we migrated to a new system that does not have the perl redirect script we were using prior)

Here is the code I am trying to use:

RewriteRule ^/Atlanta$ /pub/ed/ed_marketplace/in-person.html#cff [NC,R]

evans

eh,

There is a good treatment of special characters (and Apache’s parsing of the path and query string PRIOR to mod_rewrite) at https://issues.apache.org/bugzilla/show_bug.cgi?id=32328#c12 which suggests that you CAN access {THE_REQUEST} to get the original, unescaped request string. It’s UGLY (and will teach you to avoid such characters if at all possible) but it is available for you to access.

Regards,

DK