2011-10-20 9 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

ご入力のためのおかげで、しかし、イムは、エラーを取得して、ここまでになるまで物事が仕事: のRewriteRuleの 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]'?仮想ディレクトリがさらにある場合は、最後の2を 'RewriteRule^restaurant /([^ /] *)/?$ restaurant- $ 1.php [L]'に置き換えることもできます。 –

関連する問題