Forum Moderators: phranque

Message Too Old, No Replies

.htaccess question

.htaccess

         

auxiv

6:26 am on Mar 26, 2010 (gmt 0)

10+ Year Member



im working with wordpress, and am trying to create an htaccess rule that will detect -> #url-part1 at the end of each request. so if I have a url that reads:
http://----.com/wordpress/this-is-my-blog-post.html#url-part1

will translate the above url to:
http://----.com/wordpress/part1/this-is-my-blog-post.html


my attempt:
RewriteRule ^(*.)#url-part1 /part1/(*.) [L]


This of course doesn't work. If it were a static url this would be less of a challenge.

thanks!

g1smd

8:36 am on Mar 26, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



RewriteRule cannot see query strings, of that you're probably already aware.

Anything after the # shouldn't be sent to the server. It's for on page use by the browser.

jdMorgan

2:28 pm on Mar 26, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only browser that sends "named anchors" (a.k.a. "URL fragments") to servers is Apple's Safari browser, and then not under all circumstances.

As g1smd states, these are for use only on the client-side, and therefore are not usually sent to and cannot be 'seen' by the server.

You could move the 'fragment' to a query string parameter (which *is* sent to the server), use client-side scripting (e.g. JavaScript) to handle fragments, or just drop the whole fragment idea as "not cool enough for all the bother."

Jim