3

http://my_domain.com/forum/index.php/blah_blah_blahどこにもリダイレクトされないようにしたい。

しかし、私はhttp://my_domain.com/something_else_that_is_not_forum/blah_blah_blahリダイレクトされたいhttp://my_domain.com/index.php/something_else_that_is_not_forum/blah_blah_blah

したがって、基本的には、http://my_domain.com/forum/プレフィックスのないものだけをリダイレクトする必要があります。

私はこれを持っています.htaccess

<IfModule mod_rewrite.c>
    # Options +FollowSymLinks -Indexes
    RewriteEngine On
    RewriteBase /

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    RewriteRule ^(?!forum.*)(.*)$ index.php/$2 [L,QSA]
</IfModule>

正規表現は私がやりたいことを正確に行うべきだと思いますが、この場合、私は間違っているようです。 http://www.getnocms.com/forum/index.php?action=admin;area=manageboards;sa=newcat;df105e678e9b=e1a979a0631bd203b6794debc16ceced

誰かがそれを正しく行う方法を知っていますか?

編集: 私はこれを使用します

<IfModule mod_rewrite.c>
    # Options +FollowSymLinks -Indexes
    RewriteEngine On
    RewriteBase /

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteCond %{REQUEST_URI} !^\/forum 
    RewriteRule (?!^forum(?:/.*|)$)^(.*)$ /index.php/$1 [L,NC,QSA]
</IfModule>

大まかに言うと、リクエストがファイル、ディレクトリ、またはシンボリックリンクを指していない/forum場合、そうでない場合、フォーラムで開始されていない場合は、/index.php/url を指します。

論理的に思えますが (まあ、RewriteCond %{REQUEST_URI} !^\/forum実際には必要ありません)、この URL にアクセスするときにまだ失敗しました:http://www.getnocms.com/forum/index.php?action=admin;area=manageboards;sa=newcat;a5272d5=2fcf142818fc9df2aabb1364942a1d14

もしかしてセミコロンで書き換えルールが効かない?わからない。

4

3 に答える 3

1
RewriteRule !^forum/ index.php/something_else_that_is_not_forum/blah_blah_blah

で始まらないもの...

于 2013-05-17T03:45:51.880 に答える
1

ルールはほぼ正しいですが、若干の変更が必要です。コードを次のように置き換えます。

<IfModule mod_rewrite.c>
    # Options +FollowSymLinks -Indexes
    RewriteEngine On
    RewriteBase /

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule (?!^forum(?:/.*|)$)^(.*)$ /index.php/$1 [L,NC]
</IfModule>
于 2013-05-17T12:04:43.003 に答える
0

あなたも試すことができます:

RewriteCond %{REQUEST_URI} !^/forum 
RewriteRule ^(.)$ http://domain.com/$1
于 2013-05-17T03:56:56.203 に答える