开发者

A little bit help in url rewriting, please!

开发者 https://www.devze.com 2023-03-11 10:37 出处:网络
I have a short question about url rewriting... I have a website. Let\'s say http开发者_开发技巧://www.example.com/

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.


RewriteRule ^a$ a.php [L]

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消