2013-06-02 5 views
5

나는 모든 www.site.com/hello to www.site.com/index.php?p=hello 을 다시려고하고 (.htaccess에서) 다음 코드로 작동합니다한다 RewriteCond

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]*)/?$ /index.php?p=$1 

그러나 나는 그렇게 www.site.com/?p=hellowww.site.com/?p=hello

유지됩니다 작업 이전 링크를 유지하려면

나는 다음과 같은 코드를 해봤지만

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !(\?p=) 
RewriteRule ^([^/]*)/?$ /index.php?p=$1 

답변

5

I 작동하지 않습니다 대답을 찾았 어.

REQUEST_URI으로 GET 매개 변수를 가져 오려고 시도하는 중 오류가 발생했습니다. 올바른 사용법은 다음과 같이 QUERY STRING이어야합니다.

RewriteCond %{QUERY_STRING} !(p=.*)$ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]*)/?$ /index.php?p=$1 
관련 문제