1

私はmod-rewriteを使用して、実際にURLを作成しています

www.example.com/public/questions.php?question_id= <int>

に行く

www.example.com/questions/ <int>

以前のアドレスを REQUEST_URI として使用することを禁止し、新しい短縮 URL のみを許可するにはどうすればよいですか?

ルールをつけたら

RewriteRule ^public public/page404_ready.php

これにより、現在変更されているすべての URL も役に立たなくなります。


(そして、これをすべて達成した場合、ページ内のすべての自分の (AJAX) リンクを新しい URL に変更する必要がありますか?)

これは現時点での私のファイルです

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]
4

1 に答える 1

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]
于 2012-06-06T12:45:52.490 に答える