2013-03-03 5 views
1

.htaccess 파일에 다음 코드가 있습니다. 파일은 하위 폴더에 있으며,/content /라고 말하면됩니다. 나는 다시 작성하는 코드 위에 기대하고 있습니다Htaccess : 다시 쓰기 규칙 문제

RewriteCond %{REQUEST_FILENAME} -s [OR] 
    RewriteCond %{REQUEST_FILENAME} -l [OR] 
    RewriteCond %{REQUEST_FILENAME} -d 
    RewriteRule ^([^/]+)(/([^/]+))?(/(edit)+)(/([^/]+))?/?$ edit.php?category=$1&slug=$3&edit=$5&password=$7 [L] 
    RewriteRule ^([^/]+)(/([^/]+)?/?)$ content.php?category=$1&slug=$3 [L] 

, &을 mydomain.com/content/edit.php?category=text1하는

  1. mydomain.com/content/text1/text2/edit/my_password 슬러그 = 텍스트 2 & 암호 = my_password 관련
  2. mydomain.com/content/text1/text2는 사용자 도메인에 & 슬러그 = 텍스트 2
  3. mydomain.com/content/text1을 mydomain.com/content/content.php?category=text1합니다. co.kr/content/content.php? categ ORY = 텍스트 1
  4. mydomain.com/content/는

이 코드가 제대로 위의 재 작성 mydomain.com/content/content.php하는, 그러나 자산 URL을 나누기. 예 : http://mydomain.com/content/js/tms.js을 다른 것으로 다시 작성합니다. css 파일과 동일합니다. 내 자산 폴더는/img,/css,/js입니다.

는 내가 그것을 자산

모든 아이디어를 어떻게이 문제를 해결하기 위해 작동 RewriteRule ^([^/]+)(/([^/]+))?(/(edit)+)(/([^/]+))?/?$ edit.php?category=$1&slug=$3&edit=$5&password=$7 [L] 라인을 주석하는 경우?

+0

가'/ 컨텐츠/텍스트 1/텍스트 2/편집/실제 파일이나 디렉토리를 my_password'? 조건에 따라 URI가 존재하는 파일/디렉토리인지 확인합니다. –

+0

@Jon "content"는 루트에있는 폴더입니다. 다른 것들은 .. – user1955714

+0

다른 것들은 실제 디렉토리가 아니라면, 첫 번째 규칙이 그것의 조건이 요청일 때 (예를 들어'/ content/text1/text2/edit/my_password') 어떻게 작동하는지 이해하지 못합니다. ** ** 기존 심볼릭 링크, 기존 파일 또는 기존 디렉토리 여야합니다. 두 번째 규칙에는 전혀 조건이 없으므로 적어도 하나는 작동하는 것을 볼 수 있습니다. –

답변

0

조건 RewriteCond %{REQUEST_FILENAME} -d은 "요청은 기존 디렉토리에 대한 것입니다."라는 의미입니다. -d 앞에 !을 추가하면 요청이 "기존 디렉토리가 아님"으로 변경됩니다.

시도 :

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/([^/]+)(/edit)+/([^/]+?)/?$ edit.php?category=$1&slug=$2&password=$4 [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/([^/]+?)/?$ content.php?category=$1&slug=$2 [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+?)/?$ content.php?category=$1 [L] 
+0

개! 그것은 "!" 그렇다면 네. 고맙습니다 :) – user1955714