如何配置网络服务器将特定页面作为默认页面?

发布于 2024-10-15 03:19:49 字数 242 浏览 5 评论 0原文

我正在使用 Lighttpd 和 Django。我已将 Lighttpd 服务器配置为将所有以“.psp”扩展名结尾的请求传递给 Django。

我的启动页面是通过 Django 提供的页面,访问方式为“http://192.168.1.198/home.psp”。我想让用户浏览此页面,而无需在网址中显式写入“home.psp”,即使用“http://192.168.1.198”

这可能吗?

感谢您提前提供的任何帮助。

I am using Lighttpd and Django. I have configured my Lighttpd server to pass all the requests ending with ".psp" extension to Django.

My startup page is a page served through Django, which is accessed as "http://192.168.1.198/home.psp". I want to enable the user to browse this page without writing "home.psp" explicitly in the url i.e. using "http://192.168.1.198"

Is this possible?

Thanks for any help in advance.

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

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

发布评论

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

评论(3

命硬 2024-10-22 03:19:49

我认为您在这里混淆了“旧”方法之间的概念,即让单个文件代表网页,这些网页本身包含在响应 django/frameworks 如何工作之前传递给解释器的代码。

如果您熟悉 apache,可以想象 django 承担了 mod_rewrite 的部分角色。 Django 和其他框架具有所谓的调度程序或路由机制。

基本上,他们遵循 MVC 模式,即应该将模型、控制器和视图分开(用 django 的说法是模型、模板和视图)。

现在,你在 django 中有一个名为 urls.py 的文件,其中包含路由(url)和方法名称的列表(通常包含在views.py 中) )来处理它们。这是一个例子:

urlpatterns = patterns('',
    url(r'^dologin

这里 testapp 是一个 python 包,views.py 是一个 python 文件,index 是一个 django 视图。该 url 是由正则表达式构造的,因此我可以将任何我想要的内容作为 url,就像 stackoverflow url 的形成方式一样。

所以基本上,您再也不需要文件扩展名了。我强烈建议你买一本关于 django 的好书——周围有几本。

, 'testapp.views.auth_login', name="auth-login-uri"), url(r'^doopenidlogin

这里 testapp 是一个 python 包,views.py 是一个 python 文件,index 是一个 django 视图。该 url 是由正则表达式构造的,因此我可以将任何我想要的内容作为 url,就像 stackoverflow url 的形成方式一样。

所以基本上,您再也不需要文件扩展名了。我强烈建议你买一本关于 django 的好书——周围有几本。

, 'testapp.views.auth_openid_login', name="auth-openid-login-uri"), url(r'^dologout

这里 testapp 是一个 python 包,views.py 是一个 python 文件,index 是一个 django 视图。该 url 是由正则表达式构造的,因此我可以将任何我想要的内容作为 url,就像 stackoverflow url 的形成方式一样。

所以基本上,您再也不需要文件扩展名了。我强烈建议你买一本关于 django 的好书——周围有几本。

, 'testapp.views.auth_logout', name="auth-logout-uri"), url(r'^login

这里 testapp 是一个 python 包,views.py 是一个 python 文件,index 是一个 django 视图。该 url 是由正则表达式构造的,因此我可以将任何我想要的内容作为 url,就像 stackoverflow url 的形成方式一样。

所以基本上,您再也不需要文件扩展名了。我强烈建议你买一本关于 django 的好书——周围有几本。

, 'testapp.views.loginform', name="login-form"), url(r'^openidlogin

这里 testapp 是一个 python 包,views.py 是一个 python 文件,index 是一个 django 视图。该 url 是由正则表达式构造的,因此我可以将任何我想要的内容作为 url,就像 stackoverflow url 的形成方式一样。

所以基本上,您再也不需要文件扩展名了。我强烈建议你买一本关于 django 的好书——周围有几本。

, 'testapp.views.openidloginform', name="openid-login-form"), url(r'^

这里 testapp 是一个 python 包,views.py 是一个 python 文件,index 是一个 django 视图。该 url 是由正则表达式构造的,因此我可以将任何我想要的内容作为 url,就像 stackoverflow url 的形成方式一样。

所以基本上,您再也不需要文件扩展名了。我强烈建议你买一本关于 django 的好书——周围有几本。

, 'testapp.views.index', name="index"), )

这里 testapp 是一个 python 包,views.py 是一个 python 文件,index 是一个 django 视图。该 url 是由正则表达式构造的,因此我可以将任何我想要的内容作为 url,就像 stackoverflow url 的形成方式一样。

所以基本上,您再也不需要文件扩展名了。我强烈建议你买一本关于 django 的好书——周围有几本。

I think you're confusing concepts here between the "old" method of having individual files represent web pages which themselves contain code that is passed off to an interpreter before being sent in a response to how django/frameworks work.

If you're familiar with apache, imagine django as in part taking on the role of mod_rewrite. Django, and other frameworks, have what's called a dispatcher, or routing, mechanism.

Basically, they subscribe to the MVC pattern that says you should separate out the model, controller and view (in django parlance, model, template and view).

Now what then happens is you have a file called urls.py in django, which contains a list of routes (urls) and names of methods (usually contained in views.py) which handle them. Here's an example:

urlpatterns = patterns('',
    url(r'^dologin

Here testapp is a python package, views.py is a python file and index is a django view. The url is constructed from regex, so I can have whatever I want as the url, much how stackoverflow urls are formed.

So basically, you never need file extensions again. I'd strongly suggest getting a good book on django - there are a few around.

, 'testapp.views.auth_login', name="auth-login-uri"), url(r'^doopenidlogin

Here testapp is a python package, views.py is a python file and index is a django view. The url is constructed from regex, so I can have whatever I want as the url, much how stackoverflow urls are formed.

So basically, you never need file extensions again. I'd strongly suggest getting a good book on django - there are a few around.

, 'testapp.views.auth_openid_login', name="auth-openid-login-uri"), url(r'^dologout

Here testapp is a python package, views.py is a python file and index is a django view. The url is constructed from regex, so I can have whatever I want as the url, much how stackoverflow urls are formed.

So basically, you never need file extensions again. I'd strongly suggest getting a good book on django - there are a few around.

, 'testapp.views.auth_logout', name="auth-logout-uri"), url(r'^login

Here testapp is a python package, views.py is a python file and index is a django view. The url is constructed from regex, so I can have whatever I want as the url, much how stackoverflow urls are formed.

So basically, you never need file extensions again. I'd strongly suggest getting a good book on django - there are a few around.

, 'testapp.views.loginform', name="login-form"), url(r'^openidlogin

Here testapp is a python package, views.py is a python file and index is a django view. The url is constructed from regex, so I can have whatever I want as the url, much how stackoverflow urls are formed.

So basically, you never need file extensions again. I'd strongly suggest getting a good book on django - there are a few around.

, 'testapp.views.openidloginform', name="openid-login-form"), url(r'^

Here testapp is a python package, views.py is a python file and index is a django view. The url is constructed from regex, so I can have whatever I want as the url, much how stackoverflow urls are formed.

So basically, you never need file extensions again. I'd strongly suggest getting a good book on django - there are a few around.

, 'testapp.views.index', name="index"), )

Here testapp is a python package, views.py is a python file and index is a django view. The url is constructed from regex, so I can have whatever I want as the url, much how stackoverflow urls are formed.

So basically, you never need file extensions again. I'd strongly suggest getting a good book on django - there are a few around.

黑白记忆 2024-10-22 03:19:49

您可能正在寻找的是 index-file.names Lighty 的配置文件中的指令。只需将“home.psp”添加到配置文件的列表中,当未指定文件名时,Lighty 就会查找它。

What you might be looking for is the index-file.names directive in Lighty's configuration file. Just add "home.psp" to the list in your configuration file, and Lighty will look for it when no filename is specified.

数理化全能战士 2024-10-22 03:19:49

我自己解决了这个问题。这就是我所做的:

我必须在lighttpd配置文件的url.rewrite-once块中添加一条语句,例如:

 url.rewrite-once = (
        "^(/media.*)$" => "$1",
        "^(/static.*)$" => "$1",
        "^/favicon\.ico$" => "/media/favicon.ico",
        "^(/)$" => "/my_project_dir/home.psp",
        "^(/.*)$" => "/my_project_dir$1",
   )

除此之外,我在urls.py中添加了以下行:

(r'^

希望这有帮助未来的某个人。谢谢楼上大家的回复。干杯!

,my_index_view_name),

希望这有帮助未来的某个人。谢谢楼上大家的回复。干杯!

I solved the problem myself. Here is what I did:

I had to add a statement inside url.rewrite-once block of lighttpd's configuration file like:

 url.rewrite-once = (
        "^(/media.*)$" => "$1",
        "^(/static.*)$" => "$1",
        "^/favicon\.ico$" => "/media/favicon.ico",
        "^(/)$" => "/my_project_dir/home.psp",
        "^(/.*)$" => "/my_project_dir$1",
   )

Apart from this, I added the following line in my urls.py:

(r'^

Hope this helps someone in the future. Thanks everybody for your replies above. Cheers!

,my_index_view_name),

Hope this helps someone in the future. Thanks everybody for your replies above. Cheers!

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