2017-01-12 7 views
0

ずにSEOフレンドリーURL私は以下のページを持っているウェブサイトを持っている:また、私は今になりたいhtacess - リダイレクト

http://www.mywebsite.com/our-services?grade=1093    // 1093 = medium) 
http://www.mywebsite.com/our-services?grade=2890    // 2890 = high) 
http://www.mywebsite.com/our-services?grade=2890&p=2   // p = page 

示されているものを変化させるためのURLパラメータを持つことができます

http://www.mywebsite.com/our-services 

親しみやすく整頓されたURLとしてこれらを持つことはできますが、301リダイレクトはありません。理想的には私は、一例として、上記のURLがなりたい:

http://www.mywebsite.com/our-services/medium-services 
http://www.mywebsite.com/our-services/high-services 
http://www.mywebsite.com/our-services/high-services/page-2 

はこの可能使用htaccessのですか?私はhtaccessを使って内部リダイレクトを考えると、ユーザーのリダイレクトなしでこれを達成できますか?ここで私はthis postを見つけましたが、これは同じ行にありますが、少し異なります。また、私はすなわちその例をしようとすると:

RewriteEngine On 

RewriteCond %{THE_REQUEST} ^GET\ /ucp/profile\.php?([^=]+)=(\S+) [NC] 
RewriteRule ^ucp/profile\.php$ /ucp/%1/%2? [R=301,L,NC] 

# Now, deal with internal rewrites (which will not cause redirection): 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^ucp/([^/]+)/([^/]+)/?$ /ucp/profile.php?$1=$2 [NC,L] 

私は私がに行くときダミーページにすることをテストしてみたとき:

mysite.com/ucp/?player/Heartfire%3f 

mysite.com/ucp/profile.php?player=Heartfire 

それは私に次のページを提供します

次のとおりです。

mysite.com/ucp/profile/heartfire 

答えて

0

RewriteCondは、エスケープするために調整が必要です?

RewriteEngine On 

RewriteCond %{THE_REQUEST} ^GET\ /ucp/profile\.php\?([^=]+)=(\S+) [NC] 
RewriteRule^/ucp/%1/%2? [R=301,L,NC,NE] 

# Now, deal with internal rewrites (which will not cause redirection): 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^ucp/([^/]+)/([^/]+)/?$ ucp/profile.php?$1=$2 [NC,L,QSA] 

# new rules for /our-services/... 
RewriteRule ^(our-services)/high-\w+/?$ $1?grade=2890 [L,NC,QSA] 
RewriteRule ^(our-services)/high-\w+/page-(\d+)/?$ $1?grade=2890&p=$2 [L,NC,QSA] 

RewriteRule ^(our-services)/medium-\w+/?$ $1?grade=1093 [L,NC,QSA] 
RewriteRule ^(our-services)/medium-\w+/page-(\d+)/?$ $1?grade=1093&p=$2 [L,NC,QSA] 
関連する問題