2017-09-26 5 views
0

によってURLからディレクトリをスキップするためにどのように私はこのhttp://localhost/test/htaccess/zero/one?id=100はhtaccessを

http://localhost/test/htaccess/のようなURLは、.htaccessファイルは、私がzeroフォルダをスキップしたい、今存在しており、直接1を移動したいプロジェクトフォルダである必要があります。私は、以下の内容でご/テスト/ htaccessファイル/フォルダの.htaccessファイルを置くURL

+0

あなたはPHPファイルがあります、あなたの名前は何ですか? – Webdesigner

+0

ゼロはフォルダ名、one.phpは私のPHPファイルです。私は.php拡張子をスキップします。 – Maruf

答えて

0

からzeroを削除するために私を助けてください拡張子を削除する

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^\.]+)$ $1.php [NC,L] 

を結び付けています

RewriteEngine On 
# Ignore all real files 
RewriteCond %{REQUEST_FILENAME} !-f 
# Ignore if we are in subdirectory zero "/test/htaccess/zero" 
RewriteCond %{REQUEST_URI} !^/?test/htaccess/zero/(.*)$ 
# only apply if we are in "/test/htaccess/" 
RewriteCond %{REQUEST_URI} ^/?(test/htaccess)/(.*)$ 
# Rewrite to php file in zero subdirectory 
RewriteRule (.*) /%1/zero/$1.php [L] 

http://localhost/test/htaccess/one?id=100を開くと、ゼロのサブディレクトリにあるone.phpファイルが応答します。