开发者

htaccess url rewriting 2 get vars

Ok .htaccess url rewriting.. I really don't get it. I need a rewriterul开发者_高级运维e to server-translate http://domain.com/?list&cat=1 to http://domain.com/list/1/ ..

Can't figure out how this exactly works. Who can help :)?

Can somebody give me a nice tutorial or something and some help with my question?

Thank you & kind regards,

SantaWhereClause Jordy


you use substituition patterns for that

example: http://domain.com/list/1

rewrite to: http://domain.com/index.php?list=&cat=1

rewrite rule: RewriteRule /list/([0-9]+) /index.php?list&cat=$1

the () around [0-9]+ bind to $1 if you have other () they will bind to $2, $3, etc.

if you want the other way around just adapt the regular expression, but usualy you want this way.


Options +FollowSymlinks

RewriteEngine On

RewriteCond %{QUERY_STRING} cat=(.*)

RewriteRule ^list /list/%1

(I think!)


RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\/(.*)/$ index.php?ond=$1&cat=$2 [L]
RewriteRule ^(.*)/$ index.php?ond=$1 [NC]

This was the solution.

Needed request_filename to keep the images, js, css etc and edited every url too http://'.$_SERVER['SERVER_NAME'].'/etc/etc/etc.jpg

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜