使用 htaccess 重写创建我自己的tinyurl
我想在我的 htaccess 文件中创建一个 mod 重写,可以将
mydomain.com/abCdE
更改为: mydomain.com/controller/view/parameter/abCdE
提前致谢!
PS我正在使用 Zend Framework
Stefano
I would like to create a mod rewrite in my htaccess file that will can change this:
mydomain.com/abCdE
to this:
mydomain.com/controller/view/parameter/abCdE
Thanks in advance!
P.S. I'm using Zend Framework
Stefano
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我过去创造过这种东西。这就是您想要的:
这样您网站上的每个现有文件和目录仍然可以工作,并且其他所有内容(*包括任何额外的 _GET 参数!)也将被传递。
如果您将其放入 .htaccess 文件中,请将 RewriteRule 更改为
This 应该可以彻底回答您的问题。
I've created this sort of thing in the past. This is what you want:
That way every single existing file and directory on your website will still work, and every thing else (*including any extra _GET parameters!) will be passed too.
If you're putting this inside an .htaccess file, change the RewriteRule to
This should thoroughly answer your question.
您可以使用 mod_rewrite 将所有(或几乎所有)请求重定向到一个 PHP 文件,并使其完成这项工作:
如果您想保留某些页面,您可以设置条件:
You can use
mod_rewrite
to redirect ALL (or almost all) requests to one PHP file, and make it do the job:If you want to leave some pages, you may put conditions: