如何使用mod_rewrite
我有一个网站(例如sports.com),我想设置mod_rewrite,以便“football.sports.com/america”的访问者显示来自“sports.com/stuff/place.php? id=美国”。我仍然希望赤裸裸的“sports.com”访问者能够看到“stuff/index.php”。
抱歉,我对此真的是新手。我已经尝试过几次但失败了,这就是我到目前为止所拥有的......
IndexIgnore *
Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} football\.sports\.com [NC]
RewriteRule ^([^/.]+)$ stuff/place.php?id=$1 [L]
RewriteRule (.*) stuff/index.php?%{QUERY_STRING}
任何帮助将不胜感激。
I have a site (sports.com, let's say) and I'd like to set up mod_rewrite so that a visitor to "football.sports.com/america" is shown content from "sports.com/stuff/place.php?id=america". I'd still like visitors to the naked "sports.com" to see "stuff/index.php".
Sorry, I'm a real newb with this. I've tried and failed several times, heres what I have so far...
IndexIgnore *
Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} football\.sports\.com [NC]
RewriteRule ^([^/.]+)$ stuff/place.php?id=$1 [L]
RewriteRule (.*) stuff/index.php?%{QUERY_STRING}
Any help would be massively appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以这样做:
将
football.sports.com/america[/]
重定向到football.sports.com/stuff/place.php?id=america
。这是一条静态规则:例如,它不适用于法国。如果您需要通用的方式,您需要:
要重定向裸网站,请添加:
将football.sports.com/重定向到football.sports.com/stuff/index.php
最终您可以添加必要的查询字符串。
You can do this like:
Redirects
football.sports.com/america[/]
tofootball.sports.com/stuff/place.php?id=america
. This is a static rule: it won't work with france for example.If you need a generic way you need :
To get naked site to be redirected, add:
Redirects football.sports.com/ to football.sports.com/stuff/index.php
Eventually you can add the query string of necessary.