2013-10-11 2 views
1
에서

내 프로젝트는이 URL을 http://domain.com/index.php?page=home/contactus 같은 http://domain.com/index.php?page=events/announcementdetails/80의 index.php를 피하기위한 htaccess로? 페이지 = URL

나는 주어진 URL에 80 같은 의 index.php? 페이지 = 및 매개 변수를 피하려고 URL을 http://domain.com/home/contactushttp://domain.com/events/announcementdetails으로 변경하고 싶습니다. htaccess 파일을 사용하여 어떻게이 작업을 수행 할 수 있습니까?

답변

0

한번에 문서의 루트에 htaccess로 파일이 추가 :

RewriteEngine On 

RewriteCond %{THE_REQUEST} \ /index\.php\?([^\ ]*) 
RewriteRule^/%1 [L,R=301] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?$1 [L,QSA] 
0

httpd.conf 통해 mod_rewrite.htaccess을 활성화하고 다음 DOCUMENT_ROOT/.htaccess 파일에이 코드를 넣어 :

RewriteEngine On 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?page=([^\s&]+) [NC] 
RewriteRule^/%1? [R=301,L,NE] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)$ /index.php?page=$1 [L,QSA]