2012-06-06 1 views
1
내가 정말 내 URL을 만들기 위해 유행의 재 작성을 사용하고

을-다시 작성 모에 사용되는 어떻게 이전 주소가 REQUEST_URI로 사용되는 것을 금지하고 내 단축 URL을 통해서만 허용 할 수 있습니까? 내가 너무 내 모든 현재 변경 URL을 쓸모있게 규칙는</p> <pre><code>www.example.com/public/questions.php?question_id= <int> </code></pre> <p>이</p> <pre><code>www.example.com/questions/ <int> </code></pre> <p>로 이동

RewriteRule ^public public/page404_ready.php 

을 넣으면

.


(그리고이 모든 작업을 수행 할 경우, 나는 새로운 URL로 페이지에있는 모든 내 자신의 (AJAX) 링크를 변경하려면?해야합니다)

이 순간에 내 파일입니다

RewriteRule ^questions/topics/(.+)/?$ public/questions.php?topics=$1 [NC,L] 
RewriteRule ^questions/ask/?$ public/ask_question.php [NC,L] 
RewriteRule ^questions/edit/([0-9]+)/?$ public/edit_question.php?question_id=$1 [NC,L] 
RewriteRule ^questions/posts/edit/([0-9]+)/?$ public/edit_post.php?post_id=$1 [NC,L] 
RewriteRule ^users/edit/([0-9]+)/?$ public/edit_profile.php?user_id=$1 [NC,L] 
RewriteRule ^(admin)/?$ public/$1/index.php [NC,L] 
RewriteRule ^(admin)/(\w+)/?$ public/$1/$2.php [NC,L] 
RewriteRule ^(admin)/(\w+)/(\d+)/?$ public/$1/$2.php?topic_id=$3 [NC,L] 

RewriteRule ^([\w\-]+)/?$ public/$1.php [NC,L] 

#RewriteRule ^public public/page404_ready.php [L] 
+0

(예, 모든 링크와 아약스 URL을 변경해야합니다.) – Gerben

+0

@Gerben 건배! – yehuda

답변

3
내가 정확하게 당신이이 규칙에 뭘 하려는지 이해가 안

:

RewriteRule ^public public/page404_ready.php 

당신이 사용할 수있는 코드를 다음

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

# this is your current rule 
RewriteRule ^questions/([0-9]+)/?$ public/questions.php?question_id=$1 [L,NC,QSA] 

# this is the URL you want to block 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+public/questions\.php\?question_id=[0-9]+[&\s] [NC] 
RewriteRule^- [F] 
+0

나는 지금 내 파일로 내 질문을 업데이트했다. 사람들이 www.example.com/public/questions.php?question_id= 에 가지 못하게하려면 어떻게해야합니까? – yehuda

+0

위의 두 번째 규칙은 'www.example.com/public/questions.php?question_id= '으로가는 사람들을 차단합니다.이 규칙을 .htaccess에 넣고 해당 URI를 방문하면 금지 된 오류가 발생합니다. – anubhava

+0

감사합니다. [A-Z] {3,}은 무엇에 관한 것입니까? – yehuda