【发布时间】:2013-05-19 16:02:00
【问题描述】:
我知道这个问题被问了很多,但我不知道为什么它对我不起作用 :-? 这是我的 htaccess:
Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
# Rules
RewriteRule ^(.*)$ index.php
此代码应该重写任何路径的任何链接,包括 index.php 的任何子域,但它没有。
域名也不应该进入htaccess,因为它是未知的!!! 我从 127.0.0.1 调用这个 htaccess,许多网站应该链接到 localhost:
/etc/hosts
127.0.0.1 localhost
127.0.1.1 mypc
127.0.0.1 google.com
127.0.0.1 example.com
在这里,我的浏览器确实可以成功浏览 google.com 或 example.com,但找不到它们的子域,例如 sub1.google.com 或 sub1.example.com。
index.php
<?php
$uri = 'http'. ($_SERVER['HTTPS'] ? 's' : null) .'://'. $_SERVER['HTTP_HOST'].$_SERVER[REQUEST_URI];
print_r($uri);
?>
有人知道这个 .htaccess 代码是如何对子域起作用的吗?
【问题讨论】:
标签: .htaccess mod-rewrite url-rewriting webserver localhost