2011-03-24 256 views
0

我想重定向http://localhost/xyz index.php。這個index.php位於/ var/www/xyz /中。我有一個具體的理由來做到這一點。.htaccess重定向

重寫規則http://localhost/xyz的index.php不工作,我不知道爲什麼

感謝 讓

+0

你想重定向到/xyz/index.php? – 2011-03-24 19:46:57

+0

我也有RewriteRule $ frame.php,這會做的是localhost/xyz/e會重定向到frame.php。但/ xyz /不會去index.php。現在,這似乎很愚蠢,如果你可以理順 – X10nD 2011-03-24 20:13:59

回答

1

應用規則的路徑,而不是到URL(=離開http://localhost)。

RewriteRule /xyz /index.php 

該規則也適用於/ bla/xyz和/ xyzabc。甚至到/ blah/xyzabc。第一個參數是可以改變的,以禁止這樣的:

RewriteRule ^/xyz$ /index.php 

如果您想了解更多的RewriteRules,我想的cheatsheet將會對您有用:http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/也許谷歌的一些重寫規則的例子。

+0

我也有RewriteRule $ frame.php,這將做什麼是http:// localhost/xyz/e將重定向到frame.php。但/ xyz /不會去index.php – X10nD 2011-03-24 20:11:15