htaccess的重定向与变数 [英] htaccess redirection with variables
本文介绍了htaccess的重定向与变数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以帮助我?我想要做的是重定向 -
Can someone help me with this? What I'm trying to do is redirect -
http://www.domain.com/testpage
到
http://www.domain.com/index.php?id=testpage
如果该网页不上服务器存在。
if that page does not exist on server.
推荐答案
使用的.htaccess和的重写规则
Using .htaccess and RewriteRule
# -f means "is it a file" !-f "not(is it a file)"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?/id=$1 [L]
# RewriteRule takes a regular expression and an output followed by
# a set of instructions in the brackets.
# in this case, we're saying, 'take anything not found and add it to index.php?id=
# [L] means that this should be considered a final instruction -- no more rules
# should apply here.
这篇关于htaccess的重定向与变数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文