搜索引擎友好的URL与的.htaccess [英] SEO friendly URL's with .htaccess

查看:203
本文介绍了搜索引擎友好的URL与的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以请帮我做一些URL重写?

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

和希望他们被要求为:

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

我使用的是IIS并在第一次我的托管服务提供商使用的ISAPI_Rewrite用的httpd.ini文件,现在他们已改用赫利与猿.htaccess文件。 请参阅: http://www.isapirewrite.com/ 和的 http://www.helicontech.com/ape/

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/

我试了一下被Isapi_Rewrite方式:

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.

建议?

推荐答案

试试这个

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

第三重定向照片/野生动物=真正的测试/ gallery.asp ID =野生动物和放大器; A =真正的

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

如果你不想重定向用= TRUE,只是给了QSA)

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

这篇关于搜索引擎友好的URL与的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆