[英]SEO friendly URL's with .htaccess
Can anybody please help me with some URL rewriting? 有人可以帮我重写一些URL吗?
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/photos/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. 我使用的是IIS,最初我的托管服务提供商使用的是带有httpd.ini文件的ISAPI_Rewrite,现在他们已使用.htaccess文件切换到Helicon Ape。 See: http://www.isapirewrite.com/ and http://www.helicontech.com/ape/
请参阅: http : //www.isapirewrite.com/和http://www.helicontech.com/ape/
I tried it the ISAPI_Rewrite way: 我尝试了ISAPI_Rewrite的方式:
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 第三将重定向照片/野生动物?a = true到test / gallery.asp?id = wildlife&a = true
if you don't want to redirect with a=true, just give out QSA ;) 如果您不想使用a = true进行重定向,只需给出QSA;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.