2011-12-07 18 views
2

Apache(.htacessの方が良い)で単純なURLの書き換えを行う必要があります 目的は単純化されたURLを取得することです。.htaccess単純なリダイレクト

次のようないくつかのフォルダを除き http://www.mysite.com/username/

http://www.mysite.com/ana/はので、私のユーザーが単純化されたURLを持っている... http://www.mysite.com/artiste-bio.php?username=ana

http://www.mysite.com/john/http://www.mysite.com/artiste-bio.php?username=john

などに行くに

を行きます

http://www.mysite.com/images/ 
http://www.mysite.com/scripts/ 
http://www.mysite.com/admin/ 

これは.htaccessで行うことができるものですか?

よろしく

+0

を試してみてください。難しい部分は、実際のディレクトリがリダイレクトされないようにする方法です。 –

答えて

0

ものは、.htaccessファイルで行うことができます。

# Enable Rewriting 
RewriteEngine on 

# Rewrite user URLs 
# Input: user/NAME/ 
# Output: user.php?id=NAME 
RewriteRule ^(\w+)/?$ artiste-bio.php?username=$1 

このコードは、mod_rewriteのmod_rewrite in depth

0

について非常に良いチュートリアルから抽出されたリダイレクト部分はかなり簡単です。この

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*) http://www.mysite.com/artiste-bio.php?username=$1 [L] 
関連する問題