通过一个脚本与Apache服务的域下的所有路径 [英] serve with apache all paths under a domain through one script

查看:131
本文介绍了通过一个脚本与Apache服务的域下的所有路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过托管公司[1]一个Linux / Apache服务器上托管网站。到现在为止我服务通过一个脚本参数不同的内容。一个例子是URL

i'm hosting a website through a hosting company [1] on a linux/apache server. until now i serve the different content through one script with parameters. an example url is

www.mydomain.com/pages.php?date=1-10-2008

现在我想改变的网址是由东西看起来完全像个路径URL方案。例如:

now i want to change the scheme the url is composed of to something which looks completely like a path url. eg.:

www.mydomain.com/pages/date/2008/20/1

为了这个,我需要的的URL路径的法线贴图的关闭到目录文件夹中的Apache:将所有路径的所有请求应该去一个中央脚本(pages.php),这比分析URL的路径组件。

for this i need to switch off the normal mapping of url paths to directory folders in apache: all requests to all paths should go to one central script (pages.php), which than analyzes the path component of the url.

我如何调整Apache的这个?我希望一些的.htaccess规则可以的伎俩。

how do i tweak apache for this? i hope some .htaccess rules could the trick.

[1]顺便说一句,托管公司是 godaddy.com

[1] btw, the hosting company is godaddy.com.

推荐答案

是这样的:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ! -f
RewriteCond %{REQUEST_FILENAME} ! -d
RewriteRule . pages.php

应该重写文件或目录不存在pages.php每个请求。这将让你保持静态文件(图片,样式表等)在同一个文档根目录。

should rewrite every request for a file or directory that doesn't exist to pages.php. This will allow you to keep static files (images, stylesheets, etc) in the same document root.

这篇关于通过一个脚本与Apache服务的域下的所有路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆