2011-10-20 53 views
0

我还没有想出解决方案。我想有多个虚拟目录,但不能找到如何做到这一点,而不使用PHP或某种变量。例如我想:mod_rewrite没有变量的虚拟目录

mysite.com/restaurant/ to point to mysite.com/restaurant.php 

mysite.com/restaurant/menu/ to point to mysite.com/restaurant-menu.php 
mysite.com/restaurant/location/ to point to mysite.com/restaurant-location.php 

等等,没有动态内容;我有所有的文件。

回答

2

你可以使用mod_rewrite来做到这一点!

RewriteEngine on 
RewriteRule ^restaurant/?$ restaurant.php [L] 
RewriteRule ^restaurant/menu/?$ restaurant-menu.php [L] 
RewriteRule ^restaurant/location/?$ restaurant-location.php [L] 
+0

感谢您的输入,但是我得到一个错误,直到在这里工作的事情: RewriteEngine叙述上 重写规则^餐厅/ $ restaurant.php [L] 但是当我添加的下一行 ? RewruteRule^restaurant/menu /?$ restaurant-menu.php [L] 我得到了500内部服务器错误,甚至以前工作过的/ restaurant/link都停止了。 –

+0

@Hacienda Misne soory,看看吧! – undone

+0

最后一个不应该是:'RewriteRule^restaurant/location /?$ restaurant-location.php [L]'?如果有更多的虚拟目录,你也可以用'RewriteRule^restaurant /([^ /] *)/?$ restaurant- $ 1.php [L]'来代替最后2个。 –