开发者

SEO friendly URL's with .htaccess

Can anybody please help me with some URL rewriting?

I have (for example) these pages:

www.mydomain.com/test/gallery.asp?id=2
www.mydomain.com/test/gallery.asp?id=3

and want them to be requested as:

www.mydomain.com/phot开发者_如何转开发os/people
www.mydomain.com/photos/wildlife

I'm using IIS and at first my hosting provider was using ISAPI_Rewrite with a httpd.ini file, now they have switched to Helicon Ape with a .htaccess file. See: http://www.isapirewrite.com/ and http://www.helicontech.com/ape/

I tried it the ISAPI_Rewrite way:

RewriteRule /photos/people /test/gallery.asp?id=2 [I,L]
RewriteRule /photos/wildlife /test/gallery.asp?id=3 [I,L]

But it doesn't work.

Suggestions?


try this

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^photos/(.*)$ test/gallery.asp?id=$1 [L,QSA]

first row is test if it isn't file

second row is test if it isn't directory

third will redirect photos/wildlife?a=true to test/gallery.asp?id=wildlife&a=true

if you don't want to redirect with a=true, just give out QSA ;)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜