如何在没有文件扩展名的情况下获得用户友好的URL? [英] How to get user friendly URLs without any file extensions?
问题描述
我很久以来一直在想,人们如何设法让他们的网址在没有文件扩展名的情况下工作,比如'.html'或'.apsx'。
请看这个网站,例如:
http://www.axongarside.com/Communication
http://www.axongarside.com/Communication/Compleat
http://www.axongarside.com/Brand
http://www.axongarside.com/Brand/K3-Group
他们是如何完成这项工作的?我能想到的唯一方法是为每个页面创建一个新目录,并在每个目录中都有一个索引页面,但这对于较大的网站来说是一个巨大的麻烦。有没有其他的办法?
Thankyou
通常的方法是:使用索引页(即只需创建一个目录并将 后一种方法会在Apache中使用类似的方法服务器配置: 或 对于使用WSGI的脚本(Python)或FastCGI(跨语言,这个特定的例子是从我写的Perl应用程序中分离出来的)。 URL格式将由脚本处理本身,不同的框架采取不同的方法来解决这个问题。 在Catalyst中,这是通过为子程序名称提供属性。 Dancer拥有自己的路径处理程序语法。 Web :: Simple使用子程序原型。 Django使用包含模式列表的单独文件。 I've been wondering for a long time how people manage to get their URLs to work without file extentions such as '.html' or '.apsx' on the end. Look at this website for example: How have they accomplished this? The only method I can think of would be to create a new directory for each page and have an index page in each directory but this would be a huge hassle for a larger website. Is there any other way? Thankyou The three most common ways are to: The latter approach would use something like this in an Apache server configuration: or For scripts using WSGI (Python) or FastCGI (Cross-language, that particular example was cribbed from a Perl application I'm writing) respectively. The URL format would be handled by the script itself, and different frameworks take different approaches to the problem. In Catalyst, this is done by providing attributes to subroutine names. Dancer has its own route handler syntax. Web::Simple uses subroutine prototypes. Django uses a separate file containing a list of patterns. 这篇关于如何在没有文件扩展名的情况下获得用户友好的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! index.html code> file)。
WSGIDaemonProcess示例processes = 2 threads = 15 display-name =%{GROUP}
WSGIProcessGroup示例
WSGIScriptAlias / /hosts/example.com/application/wsgi.py
SetHandler fcgid -script
Alias / /hosts/example/application.fcgi/
http://www.axongarside.com/Communication
http://www.axongarside.com/Communication/Compleat
http://www.axongarside.com/Brand
http://www.axongarside.com/Brand/K3-Group
index.html
file in it).WSGIDaemonProcess example processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup example
WSGIScriptAlias / /hosts/example.com/application/wsgi.py
SetHandler fcgid-script
Alias / /hosts/example/application.fcgi/