2011-09-19 5 views
4

저는 htaccess를 처음 사용하고있어서 도움이 필요한 문제가 있습니다. 내 사이트에는 루트 폴더에서 콘텐츠를 제공하려는 폴더 (실제로 비어 있음)가 있습니다. htaccess 루트 폴더의 내용을 표시 할 폴더 URL을 다시 작성하십시오.

는 구조는 다음과 같이 말할 수 있습니다 :

example.com

-folder1 

    -index.php 

    -anotherpage.php 

    -.htaccess 

그래서, 누군가는 그가 그와 같은 URL을 볼 수 있지만 얻을 것이다 example.com/folder1/index.php에 갈 때 example.com/index.php의 콘텐츠 example.com/folder1/anotherpage.php를 방문하면 example.com/anotherpage.php에서 콘텐츠를 가져옵니다. 물론 example.com/index.php에 직접 방문하면 example.com/index.php가 표시됩니다.

나는 반대가 아니라 많은 것을 보여주는 예를 발견했다. 또한 명확히하기 위해, 나는 URL을 위조하여 실제로 folder1에 페이지가 있다는 것을 재 지정하지 않고 재 작성하고 싶다.

도움이 될 것입니다.

답변

3

사용 루트 폴더에서이 htaccess로 :

# Enable mod_rewrite 
RewriteEngine on 
# ^: Start with 
# folder1: name the folder 
# (\/?): Can containt an ending slash eg: folder1/ or folder1 
# $: End with 
# [QSA]: Query string append, means you can use %name=value 
# [NC]: Non Case: Case insensitive 
# [L]: Last rule, stop if this rule match the url 
RewriteRule ^folder1(\/?)$ /index.php [QSA,NC,L] 
# (.*): Everything 
# $1: the matching filename- file must exists. 
RewriteRule ^folder1/(.*)(\/?)$ /$1 [QSA,NC,L] 
작동하지 않습니다
+0

.... 당신이이 규칙을 넣어 않았다 – Ferdous

+2

? 너 .htaccess 보여 줄 수있어? –

+0

각 라인이하는 일을 설명 할 수 있습니까? – User

관련 문제