2016-10-05 7 views
0

私は[B]書き換えルール「をパラメータとしてURLは」

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f 
RewriteCond %{THE_REQUEST} \s/+(\S+) 
RewriteRule (.*) index.php?i=%1 [B,L] 

は残念ながら行う方法を見つけ出すことはできませんApacheの.htaccessを使用してフラグを「パラメータとしてURLを」疥癬 Openi:

<configuration> 
    <system.webServer> 
     <defaultDocument enabled="true"> 
     <files>  
      <clear/>    
      <add value="index.php"/> 
     </files> 
     </defaultDocument> 
     <modules runAllManagedModulesForAllRequests="true"/> 
     <rewrite> 
      <rules> 
       <rule name="rule" stopProcessing="true"> 
        <match url="^(.*)$" ignoreCase="false" /> 
        <conditions> 
         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> 
        </conditions> 
        <action type="Rewrite" url="index.php?i={R:1}" appendQueryString="true" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration> 

IISのweb.configファイルでも同じことが... web.configファイルがhttp://localhost/dir/web.configの下にあると言う

結果をしますNG http://localhost/dir/http://localhost/dir/example実行は正しくはindex.phpが、アクセスhttp://localhost/dir/i/http://example.orgリターンは500The page cannot be displayed because an internal server error has occurred.

が予想されるエラー:http://localhost/dir/i/http://example.orgは、IISを使用することはできませんようだdir/i/http://example.org

$_GET['i']値とのindex.phpを実行する必要がありますURL :/ ...これにはどのような回避策がありますか?

http://www.htaccesstowebconfig.comのようなツールは、.htaccessを正しく変換しません。ヘルプ/アドバイスは非常に高く評価されます。

答えて

0

私は:/を含むURLを対応するための方法を見つけるし、複数のスラッシュ値/クエリ://...(例URL http://localhost/dir/i/http://example.org)を返す唯一の方法は、UNENCODED_URLを使用していました。 答え休閑:

<rule name="Index" stopProcessing="true"> 
    <match url=".*" /> 
    <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="index.php?i={UNENCODED_URL}" appendQueryString="true" /> 
</rule> 

お知らせを、それが/dir/i/http://example.orgのような/を初め値を返します。

すべての問題(これは必要ありません)を解決するために、任意の恩恵を与えていない

<system.web> 
    <httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="" relaxedUrlToFileSystemMapping="true" AllowRestrictedChars="1" UrlSegmentMaxLength="2048" /> 
    <pages validateRequest="false" /> 
</system.web> 
<security> 
    <requestFiltering allowDoubleEscaping="false" /> 
</security> 

のように、特殊記号を許可するように周りのハッキング。

アップデート:ローカルのWindows 10マシンで正常に動作しますが、Azureサーバーでもエラー500が返されます。理由は分かりません。

ModuleName IIS Web Core 
Notification BEGIN_REQUEST 
HttpStatus 500 
HttpReason Internal Server Error 
HttpSubStatus 19 
ErrorCode The specified path is invalid. 
(0x800700a1) 
ConfigExceptionInfo \\?\D:\home\site\wwwroot\i\http:\web.config (0) :Cannot read configuration file 
関連する問題