2016-09-26 4 views
1

동일한 폴더에 포함 된 두 개의 서로 다른 파일에서 작동하는 다시 쓰기 규칙을 만들고 싶습니다.두 개의 다른 파일에서 동일한 .htaccess의 RewriteRule

localhost/nameOfUser will be applied to index.php 
localhost/nameOfUser?score=12 or localhost/nameOfUser/12 will be applied to post.php 

내가 두 번째 시작이 작동하려면

RewriteRule ^(.*)$ post.php?user=$1 [NC,QSA] 

를 추가하면 나는

RewriteEngine On 
RewriteRule ^(css|fonts)($|/) - [L] 
RewriteRule ^(php|avatars)($|/) - [L] 
RewriteRule ^(user|post)($|/) - [L] 
RewriteRule ^(.*)$ index.php?user=$1 [NC,QSA] 

으로 첫 번째 작업을 관리했지만, 첫 번째는하지 않습니다.

같은 .htaccess 파일에있는 두 개의 서로 다른 파일을 다시 쓸 수 있습니까?

답변

1

다음을 줘 시도 규칙 : 당신이 nameOfUser?score=12 작업 할 경우, 그러나

RewriteEngine On 
RewriteRule ^(css|fonts|php|avatars|user|post)($|/) - [L] 
RewriteRule ^([^/]+)$ index.php?user=$1 [NC,QSA,L] 
RewriteRule ^([^/]+)/([^/]+)$ post.php?user=$1&score=$2 [NC,QSA,L] 

을, 당신은 그들을 수정해야합니다 :

로컬 호스트/사용자에
RewriteEngine On 
RewriteRule ^(css|fonts|php|avatars|user|post)($|/) - [L] 
RewriteCond %{QUERY_STRING} ^$ 
RewriteRule ^([^/]+)$ /index.php?user=$1 [NC,QSA,L] 
RewriteCond %{QUERY_STRING} ^score=(.+)$ 
RewriteRule ^([^/]+) /post.php?user=$1&score=%1 [NC,L] 
+0

/점수 아무튼 ' t show css. 그냥 일반 텍스트. – Mirakurun

+0

@Mirakurun HTML을 업데이트하여 '태그를 포함시킵니다. ''태그의 처음에 표시되어야합니다. – hjpotter92

관련 문제