0

URL http://www.mysite.com/usernameを入力して、ユーザーが自分のページにアクセスできるようにしたい

http://www.mysite.com/usernameをhttp://www.mysite.com/profile/usernameにリダイレクトするに

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On



  # Get rid of index.php
  RewriteCond %{REQUEST_URI} /index\.php
  RewriteRule (.*) index.php?rewrite=2 [L,QSA]


  # Rewrite all directory-looking urls
  RewriteCond %{REQUEST_URI} /$
  RewriteRule (.*) index.php?rewrite=1 [L,QSA]



  # Try to route missing files
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} public\/ [OR]
  RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
  RewriteRule . - [L]



  # If the file doesn't exist, rewrite to index
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]



   RewriteRule ^([A-Za-z_-]+)$ /profile/$1 [R] 


</IfModule>

なぜこれがうまくいかないのですか?

4

2 に答える 2

2

自分のルールを他のルールの前に置いてみてください。この方法で開始できます。

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([A-Za-z_-]+)$ /profile/$1 [R]
于 2011-09-12T08:14:34.410 に答える
2

ユーザーが既に持っているモジュールと同じ名前を持っているという問題が発生する可能性があることに注意してください。たとえば、誰かが (何らかの理由で) グループに名前を付けていて、グループ プラグインをインストールして有効にしているとします。

于 2012-09-07T18:40:59.157 に答える