2010-12-28 15 views
1

私はサブドメインsubdomain.domain.com/appname上で実行されているdjangoアプリケーションを持っていますが、私のURLにはそのアプリケーション名が表示されません。私は、これは、要求されたURLがsubdomain.domain.com/homeあり、それはsubdomain.domain.com/appname/homeから提供された場合をaccompishes .htaccessのサブディレクトリを偽装するための.htaccessを持つmod_rewrite

RewriteEngine On 

RewriteCond %{REQUEST_URI} !admin 
RewriteCond %{REQUEST_URI} !appname 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ /appname/$1 [L] 

を経由して、これを達成しました。

しかし、私はまた、要求されたURLがsubdomain.domain.com/appname/homeであり、表示されたURLがsubdomain.domain.com/homeに変更され、ルールをトリガする逆を達成したいと思います上とsubdomain.domain.com/appname/home

から提供された私は、次のことを試してみましたが、私はループ

RewriteEngine On 

RewriteCond %{REQUEST_URI} appname 
RewriteRule ^appname/(.*)$ /$1 [N,R=301] 

RewriteCond %{REQUEST_URI} !admin 
RewriteCond %{REQUEST_URI} !appname 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ /appname/$1 [L] 

答えて

5

は「N」フラグなしで試していましたエラー:

'next|N' (next round)
Re-run the rewriting process (starting again with the first rewriting rule). This time, the URL to match is no longer the original URL, but rather the URL returned by the last rewriting rule. This corresponds to the Perl next command or the continue command in C. Use this flag to restart the rewriting process - to immediately go to the top of the loop.
Be careful not to create an infinite loop!

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

関連する問題