2017-10-06 16 views
2

Wordpressサイトをセットアップしました。 特定のフォルダ内のファイルに対して.php拡張子を再帰的に削除する必要があります。.php .htaccessとWordpressを再帰的に削除します。

と言ってください。 www.domain.com/wordpresspage/(すべてパーマリンクで設定します)。

私は、そのフォルダのための再帰的.PHP削除する必要があります。 domain.com/gz/*

domain.com/gz/の内容が.phpの拡張子が取り除かなければなりません。しかし、このフォルダのみ。

フォルダ構造

/ 
-/images (No .htaccess rules should apply, Wordpress takes care of it.) 
-/downloads (No .htaccess rules should apply, Wordpress takes care of it.) 
-/gz (.htaccess change, to remove .php file extension, overwriting Wordpress, in this particular folder) 
-file1 (No .htaccess rules should apply, Wordpress takes care of it.) 
-file2 (No .htaccess rules should apply, Wordpress takes care of it.) 

私は拡張子を.phpの削除するには、次の.htaccessコンテンツを使用しますが、Wordpressのは、残りの世話をしているので、今、私は、1つのフォルダのみでこれを強制する必要があります前に。

#RewriteBase/
#RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+)\.php\ HTTP 
#RewriteRule ^([^.]+)\.php$ https://example.com/$1 [R=301,L] 
#RewriteCond %{REQUEST_URI} !(\.[^./]+)$ 
#RewriteCond %{REQUEST_fileNAME} !-d 
#RewriteCond %{REQUEST_fileNAME} !-f 
#RewriteRule (.*) $1.php [L] 

私はすでに、物事のトンを試してみたが、最後の数は含ま:

  1. は、すべてのページに.phpの削除古い.htaccessファイルを使用してください。これは私のパスの問題を解決しますが、サイトの残りの部分に内部サーバーエラーを与えます。
  2. そのフォルダを再帰的にフィルタリングする方法を試してみましたが、私はもはやそれが可能かどうかわかりません。 (私が試したことのほんの一部を覚えていない)。
  3. パーマリンクで.phpを追加しようとしましたが、それをリダイレクトして再度削除するので、さらに別の内部サーバーエラーが発生します。

TL; DR - 私の.htaccessファイル内の特定のパスで再帰的に.phpを削除することができるので、Wordpressはこのフォルダを無視して、自分のビジネスを処理しますか?

を追加しましたが、ヘルプの最初のラウンドの後、私の.htaccessファイルは次のようになります。

# -FrontPage- 

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* 

RewriteEngine On 
# Only apply if request starts with /gz/ 
# followed by at least one character and ends with .php 
RewriteCond %{REQUEST_URI} ^/?gz/[^.]+\.php$ 
# Redirect to the same location but without .php ant the end 
RewriteRule ^/?(.*)\.php$ /$1 [R=301,L] 

# Only apply if request starts with /gz/ followed by at least one character 
RewriteCond %{REQUEST_URI} ^/?gz/[^.]+$ 
# and the request it not a real directory 
RewriteCond %{REQUEST_FILENAME} !-d 
# and the request it not a real file 
RewriteCond %{REQUEST_FILENAME} !-f 
# Rewrite the request with .php at the end 
RewriteRule ^(.*)$ /$1.php [L] 

<Limit GET POST> 
order deny,allow 
deny from all 
allow from all 
</Limit> 
<Limit PUT DELETE> 
order deny,allow 
deny from all 
</Limit> 

AddType application/x-httpd-php-old .php 

<IfModule security_module> 
    SecFilterEngine Off 
</IfModule> 
<IfModule security2_module> 
    SecRuleRemoveByID 1-99999 
    SecRuleRemoveByTag unoeuro 
</IfModule> 

パーマリンクを再適用した後、Wordpressのは、.htaccessファイルにこのセクションを追加します事前に

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 

おかげで、

L

あなたは何ができるか

答えて

2

あなたは、例えば要求のであれば、次の

RewriteEngine On 
# Only apply if no rewrite 
RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
# Only apply if request starts with /gz/ 
# followed by at least one character and ends with .php 
RewriteCond %{REQUEST_URI} ^/?gz/[^.]+\.php$ 
# Redirect to the same location but without .php ant the end 
RewriteRule ^/?(.*)\.php$ /$1 [R=301,L] 

# Only apply if request starts with /gz/ followed by at least one character 
RewriteCond %{REQUEST_URI} ^/?gz/[^.]+$ 
# and the request it not a real directory 
RewriteCond %{REQUEST_FILENAME} !-d 
# and the request it not a real file 
RewriteCond %{REQUEST_FILENAME} !-f 
# Rewrite the request with .php at the end 
RewriteRule ^(.*)$ /$1.php [L] 

です/gz/gz5.phpは/ gz/gz5にリダイレクトされます。 、リクエストが/ gz/gz5の場合、/gz/gz5.phpに書き換えられます。

関連する問題