human
human

Reputation: 25

A little bit help in url rewriting, please!

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.

Upvotes: 0

Views: 126

Answers (2)

Tomas Reimers
Tomas Reimers

Reputation: 3292

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/.

Upvotes: 1

Rizwan Sharif
Rizwan Sharif

Reputation: 1119

RewriteRule ^a$ a.php [L]

RewriteRule ^c/(.*)/(.*) c.php?i=$1$2

Upvotes: 1

Related Questions