Question: I want to rewrite `http://example.com/articles.html#first-article` with `http://example.com/articles/first-article`

Is it possible to rewrite?

I tried using following but didn't work for me:

```
RewriteRule ^articles/(.+)$ /articles\.html\#$1

```

Answer: 
The `#` can be added in the substitution URL with the NE flag. Check:

* [This Apache link](http://httpd.apache.org/docs/2.2/rewrite/advanced.html#redirectanchors) that describes specifically how to `redirect anchors`.
* [This W3C Protocols link](http://www.w3.org/Protocols/HTTP/Fragment/draft-bos-http-redirect-00.txt) and [this one](http://www.w3.org/TR/cuap#uri).
* [This answer in SO is pretty complete](https://stackoverflow.com/questions/2286402/url-fragment-and-302-redirects).
* [Another answer in SO](https://stackoverflow.com/questions/15106056/mod-rewrite-in-htaccess-with-paging-system).
* [Another answer in SO](https://stackoverflow.com/questions/15033757/mod-rewrite-keeps-anchor-link/15034083#15034083) (mine).

So, you may try this:

```php
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}  !articles\.html      [NC]
RewriteCond %{REQUEST_URI}  ^/articles/([^/]+)/? [NC]
RewriteRule .*       /articles.html#%1           [R,NE,L]

```

Redirects

`http://example.com/articles/parameter`

To

`http://example.com/articles.html#parameter`

String `articles` is assumed to be fixed while `parameter` is assumed to be variable.
No, it's not possible. The *URL fragment* (everything from `#` on) not even gets sent to the server.

Maybe you want to consider a JavaScript based solution, where the actual content will be loaded via AJAX dependent on the fragment. You will find some useful information about this method here: [What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?](https://stackoverflow.com/questions/3009380/whats-the-shebang-hashbang-in-facebook-and-new-twitter-urls-for)