发布于 2024-11-09 04:23:58 字数 8 浏览 0 评论 0原文

continue

I am working on a project and I want to make the urls similar with the ones in use now.

For example, on stackoverflow, the urls do not end in .php (or any server side extension for that matter).

I want to be able to achieve that, I just do not know hot to go about it.

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

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

发布评论

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

评论(2

自由如风 2024-11-16 04:23:58

取决于你真正想做什么。 Stacko 可以通过基本控制器路由所有请求。例如,要在 Apache 中执行此操作,您可以:

# if no file extension exists, route request to controller
RewriteCond   %{REQUEST_URI} !\.+
RewriteRule   ^/(.*) /Controller\.php/$1 [l]

如果您的控制器(和代码库)位于客户端代码的文件系统上的其他位置,您可以执行以下操作:

RewriteCond   %{REQUEST_URI} !\.+
RewriteRule   ^/(.*) /Controller\.php/$1 [PT] # pass through to boostrapper
Alias /Controller.php /path/to/code/base/Bootstrap.php

Depends on what you want to do really. Stacko may be routing all requests via a base controller. For example, to do that in Apache you would:

# if no file extension exists, route request to controller
RewriteCond   %{REQUEST_URI} !\.+
RewriteRule   ^/(.*) /Controller\.php/$1 [l]

If your controller (and code base) live elsewhere on filesystem from client code, you can do:

RewriteCond   %{REQUEST_URI} !\.+
RewriteRule   ^/(.*) /Controller\.php/$1 [PT] # pass through to boostrapper
Alias /Controller.php /path/to/code/base/Bootstrap.php
对风讲故事 2024-11-16 04:23:58

mod_rewrite - http://httpd.apache.org/docs/current/mod/mod_rewrite .html

这是一个非常有用的重写向导,可帮助您入门

http://www.generateit .net/mod-rewrite/

另外,只需在 stackoverflow 上搜索 mod_rewrite 和 .htaccess - 您就会找到一些东西。

mod_rewrite - http://httpd.apache.org/docs/current/mod/mod_rewrite.html

This is a really useful rewrite wizard to get you started

http://www.generateit.net/mod-rewrite/

Also just have a search on stackoverflow for mod_rewrite and .htaccess - you'll find tones of stuff.

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