2017-12-11 7 views
1

WAMP에서 로컬 projet에서 작업합니다. 내가 예를 들어,이 URL을 가지고 상품 URL 콘드과 규칙을 가하고 수행하려고 무엇.htaccess URL 폴더 다시 쓰기/삭제/".php"삭제

- Project : 
    - index.php 
    - .htaccess 
    - pages : 
     - animaux : 
       - mammiferes.php 
       - oiseaux.php 
       - reptiles.php 
     - infos : 
       - access.php 
       - contact.php 
       - plan.php 
     - spectacle : 
       - reserverPlace.php 
       - spectacle.php 

: http://localhost/ProjetSyntheseFAC/mammiferes 대신 http://localhost/ProjetSyntheseFAC/pages/animaux/mammiferes.php

그래서 여기 내 폴더 계층 구조입니다. 그래서 URL에서 폴더를 삭제하고 끝에 ".php"를 삭제해야합니다.

내가 찾은 모든 시도가 작동하지 않거나 내부 서보 오류에 넣으십시오. 여기

내가 마지막으로 뭘하려 :

RewriteEngine On 
RewriteRule ^mammiferes$ /pages/animaux/mammiferes.php 

RewriteEngine On 
RewriteCond %{ENV:REDIRECT_STATUS} . [OR] 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule^- [L] 
RewriteCond %{REQUEST_URI} /(.+) 
RewriteRule !\.[a-z0-4]{2,4}$ /pages/animaux/%1.php [NC,L] 
RewriteRule (.*) /pages/animaux/$1 [L] 

누군가가 나를 도울 수

////

? 당신의 .htaccess 파일이 /project/ 하위 디렉토리에 위치하고 있으며, 상위 디렉토리는 문서 루트 인 경우

+1

[가능한 답변!] (https://stackoverflow.com/questions/11243975/rewriting-url-with-htaccess-local-in-xampp) 처음 세 줄의 코드를 사용하여 자신의'RewriteRule' 이미 위에서 한 것입니다. 만약 그것이 작동한다면 시도하고, 그렇지 않다면'error_log'가 내부 서버 오류의 의미인지 확인하십시오. – RepeaterCreeper

+0

@RepeaterCreeper URL은 여전히 ​​동일하지 않으며 htaccess가없는 것처럼 오류도 발생하지 않습니다. – Karim

답변

0
RewriteRule ^mammiferes$ /pages/animaux/mammiferes.php 

는, 당신은 RewriteRule대체에서 슬래시 접두사를 제거해야합니다. 예를 들어 : 슬래시 접두사와

RewriteRule ^mammiferes$ pages/animaux/mammiferes.php [L] 

대체는 문서 루트에 상대적입니다. 슬래시 접두사가 없으면 .htaccess 파일이있는 곳과 관계가 있습니다. 이것은 이것을 덮어 쓰는 RewriteBase 지시어가 없다고 가정합니다 (또는 RewriteBase/Project/ 서브 디렉토리로 설정하십시오).

나중에 지시문을 추가하려면 L 플래그가 포함되어야합니다.