SEO 友好的 URL,带有 .htaccess

发布于 2024-10-09 14:58:48 字数 766 浏览 0 评论 0 原文

有人可以帮我重写一些 URL 吗?

我有(例如)这些页面:

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

并希望它们被请求为:

www.mydomain.com/photos/people
www.mydomain.com/photos/wildlife

我正在使用 IIS,起初我的托管提供商使用 ISAPI_Rewrite 和 httpd.ini 文件,现在他们已切换到 Helicon Ape 和 .htaccess 文件。 请参阅:http://www.isapirewrite.com/http://www.helicontech.com/ape/

我尝试了 ISAPI_Rewrite 方式:

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

但它不起作用。

建议?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉城已无爱 2024-10-16 14:58:48

尝试

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

第一行是测试,如果它不是文件,

第二行是测试,如果它不是目录,

第三行将重定向 photos/wildlife?a=true 到 test/gallery.asp?id=wildlife&a=true

如果你不'不想用 a=true 重定向,只需给出 QSA ;)

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 ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文