1

私はこれをルートhtaccessで使用しています

RewriteEngine on
Options +FollowSymLinks

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteRule .* index.php?p=%{REQUEST_URI} [L]

これにより、 http://example.com/notexistsfolderが正常に書き換えられます

しかし、 http ://example.com/user/notexistsfolderをhttp://example.com/notexistsfolderにリダイレクトすることも必要です

これを実現するには、どのコードを追加する必要がありますか?

4

1 に答える 1

0

ディレクトリの.htaccess下に必要なコードは次のとおりです。DOCUMENT_ROOT

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

## If the request is for a valid directory
RewriteCond %{REQUEST_FILENAME} -d [OR]
## If the request is for a valid file
RewriteCond %{REQUEST_FILENAME} -f [OR]
## If the request is for a valid link
RewriteCond %{REQUEST_FILENAME} -l
## don't do anything
RewriteRule ^ - [L]

RewriteRule ^user/(.*)$ $1 [L,NC]

RewriteRule (?!^user/)^(.*)$ index.php?p=$1 [L,NC,QSA]
于 2012-06-16T17:38:45.000 に答える