2016-05-04 18 views
0

私のURLをきれいにする助けが必要です。 私はURLのようなを生成するPHPスクリプトを持っている:.htaccess URL書き換えヘルプが必要

現在
http://example.com/index.php?a=profile&u=simon 

私はそれのほとんどをきれい.htaccessを持って

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -f [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule^- [L] 

RewriteRule ^welcome/([^/]+)/?$   index.php?a=welcome&filter=$1 [NC,QSA,L] 
RewriteRule ^explore/([^/]+)/?$   index.php?a=explore&filter=$1 [NC,QSA,L] 
RewriteRule ^profile/([^/]+)/?$   index.php?a=profile&filter=$1 [NC,QSA,L] 
RewriteRule ^page/([^/]+)/?$   index.php?a=page&filter=$1  [NC,QSA,L] 
RewriteRule ^(([^/]+)+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&q=$3 [L,QSA] 

これらのルールに前のリンクは次のようになります。

http://example.com/profile&u=simon 

これを達成する方法はありますか?

http://example.com/simon 
+0

@anubhavaを= YES、私は '/ simon'や' /プロファイルこれらの2つのソリューションの1を達成したい/ simon'サイモンがあります変数のユーザ名 – NineCattoRules

+1

しかし、あなたはすでに '/ profile/simon'を扱うルールを持っています – anubhava

+0

@anubhavaありがとう、基本的に私はPHPの中で調整するものを持っています – NineCattoRules

答えて

0

あなたは、以下を使用します(既存のルールを怒鳴る)下でこれを置くことができます。

RewriteRule ^(.+)/?$ /index.php?a=profile&u=$1 [NC,L] 

これは内部

  • サイト/ fooのをリダイレクトします

    ~

    • サイト/ index.phpを?=プロファイル& Uがfoo
+0

私は試しましたが動作しません。http:// example.com/foo'は常に/ welcomeにリダイレクトされます – NineCattoRules

+0

@Simoneそれは変です! – starkeen