2012-02-15 2 views
1
와 URL의 URL에서 (더블 공간)



내 URL 구조는퍼센트는 2520 공간

http://www.example.com/folder/index.php?dir=dir1 

http://www.example.com/folder/dir1 

에서 액세스 할 수 있으려면처럼 같은 시간에 리디렉션 첫 번째 URL에서 두 번째로 내 htaccess ('폴더'에 있음)는

Options +FollowSymLinks 

RewriteEngine On 
RewriteBase /folder 

RewriteCond %{ENV:REDIRECT_STATUS} 200 
RewriteRule .* - [L] 

RewriteCond %{QUERY_STRING} ^dir=(.*)$ [NC] 
RewriteRule^%1? [L,R=301] 

RewriteRule ^(.+)/? index.php?dir=$1 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} -d 

RewriteRule ^(.*)$ index.php?dir=$1 [L,QSA] 

문제는 URL의 디렉토리 이름에 '공백'이 포함 된 경우 URL에 '공백'대신 % 2520이 표시됩니다.

htaccess를 수정하여 % 20 또는 간단히 '공백'을 나타내도록 조언 해주십시오.

답변

2

리디렉션 예에 NE를 추가하는 시도

RewriteRule^%1? [L,R=301,NE] 

편집

내 htaccess로 읽은 이후

, 당신은 더

그것을 단축의 possiblity가 보이나요

다음은 몇 가지 의견입니다.

Options +FollowSymLinks 

RewriteEngine On 
RewriteBase /folder 

RewriteCond %{ENV:REDIRECT_STATUS} 200 
RewriteRule .* - [L] 

RewriteCond %{QUERY_STRING} ^dir=(.*)$ [NC] 
RewriteRule^%1? [L,R=301] 

#this looks redundant with last rule, and could be deleted? 
RewriteRule ^(.+)/? index.php?dir=$1 [L,QSA] 

#this says if not an existing file 
RewriteCond %{REQUEST_FILENAME} !-f 
#and this says if it IS an existing directory 
#Is this what you wanted, or should it be not an existing directory i.e 
# RewriteCond %{REQUEST_FILENAME} !-d instead 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^(.*)$ index.php?dir=$1 [L,QSA] 
+0

작동합니다! 고마워요. 당신이 내 htaccess를 읽었으니 더 짧게 할 수있는 가능성이 있습니까? – Umer

+0

@ user1170540 업데이트보기 –