如何将所有地址栏请求重定向到一个索引页?并使用请求的子文件夹作为输入

时间:2011-09-21 03:01:49

标签: php javascript html ajax

我正在使用PHP,Ajax,JS和HTML,经过多次搜索后,我发布的是go-google-plexed。

如何让访问www.foo.com/bar的用户访问www.foo.com/index.php并使用 bar 作为输入?

我想避免为每个可能的值创建一个文件夹。

我想在地址栏中保留/栏

3 个答案:

答案 0 :(得分:2)

在这里使用Apache mod_rewrite exampleusing php,但是这样的uri:

http://example.com/index.php/controller/action/variables

答案 1 :(得分:0)

您想查看mod_rewrite

答案 2 :(得分:0)

检查位置并通过javascript更改为您想要的任何内容:

<script type="text/javascript">
// var x = ( cut out part of the current location )
// Then replace with whatever:
location.replace('http://www.example.com/');
</script>

示例:

http://www.tizag.com/javascriptT/javascriptredirect.php

http://andylangton.co.uk/articles/javascript/javascript-redirect-scripts/

http://www.javascriptredirect.com/timed.htm


此外,这里有一个替代mod_rewrite的php(这是你应该使用的,但如果你不能,还有其他方法):

php alternative to mod_rewrite