0

I have a short question about url rewriting...

I have a website. Let's say http://www.example.com/

with some subsites:

http://www.example.com/a.php
http://www.example.com/b.php

etc...

and some "special" urls like

http://www.example.com/c.php?i=1#link1
http://www.example.com/c.php?i=1#link2
http://www.example.com/c.php?i=2#link1

Now I would like to write a .htaccess file to convert current urls into rewritten urls like

http://www.example.com/a/
http://www.example.com/c/1/#link1

I'm not an expert in url rewriting, so could somebody please help me?

Best reagards.

human
  • 25
  • 1
  • 4
  • When asking a url-rewriting question, it is most helpful if you provide some input-output pairs. One specific example, and the general rule, in plain English, would be good. – Roland Illig Jun 03 '11 at 21:59

2 Answers2

1
RewriteRule ^a$ a.php [L]

RewriteRule ^c/(.*)/(.*) c.php?i=$1$2
Rizwan Sharif
  • 1,089
  • 2
  • 10
  • 20
1
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^a.php a/
RewriteRule ^b.php b/

Should work as far as your static pages go, you can not rewrite the hash because the hash is not sent to the server (as discussed here). If you need to rewrite the hash I would suggest changing the hash to another GET variable (eg u), in that case just add this to your htaccess: RewriteRule ^c.php?i=(.*)&u=(.*) c/$1/$2. If you simply intend to leave the anchor though, you can omit it from your rewrite and everything should be fine (...becuase the server never sees the hash/pound symbol), and in that case you should add this to your code RewriteRule ^c.php?i=(.*) c/$1/.

Community
  • 1
  • 1
Tomas Reimers
  • 3,234
  • 4
  • 24
  • 37
  • RewriteRule ^b.php b/ whats this rule doing? – Rizwan Sharif Jun 03 '11 at 22:05
  • He said he had some static pages and cited `http://www.example.com/a.php` and `http://www.example.com/b.php` as examples. I'm just being thorough and telling him how he could rewrite if he had another page. – Tomas Reimers Jun 05 '11 at 00:39