2016-07-11 16 views
0

にhtaccessファイルを使用してURLをredicectする私はここでidは1から100までダイナミックで変更することができどのようにPHP

www.example.com/article/category/12` 

www.example.com/babycare/general_help/category.php?id=12 からこの をredirecyたいのは私のhtaccessファイルは

です
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [QSA,L] 
IndexIgnore * 

//これは動作しません。

RewriteCond %{THE_REQUEST} /babycare/general_help/cetegory\.php\?id=([^\s]+)  [NC] 
    RewriteRule^/article/category/%1? [L,R] 

//この301リダイレクト

を働いている/ベビーケア/ general_help /記事

Redirect 301 /babycare/general_help /article 
Redirect 301 /babycare/aboutus.php /about 
Redirect 301 /babycare/contactus.php /contact 
Redirect 301 /babycare/login.php /login 
Redirect 301 /babycare/pass.php /pass 
Redirect 301 /babycare/registrationform.php /registrationform 
Redirect 301 /babycare/termsandconditions.php /termsandconditions 
Redirect 301 /babycare/disclaimer.php /disclaimer 
Redirect 301 /babycare/your_privacy.php /your_privacy 
Redirect 301 /babycare/faq.php /faq 
Redirect 301 /babycare/useful-links.php /useful-links 
Redirect 301 /babycare/faq.php /faq 
Redirect 301 /babycare/whyusethisservice.php /how_can_help 
Redirect 301 /babycare/sitemap.php /sitemap 
Redirect 301 /babycare/guarantee.php /satisfaction 

//この静的なページ

Redirect 301 /babycare/consultation.php /consultation/first_time 
Redirect 301 /babycare/phone_package_detail.php /consultation/support_options 
RewriteCond %{THE_REQUEST} /babycare/testimonials\.php\?id=7 [NC] 
RewriteRule^/testimonial/cat/5? [L,R] 
RewriteCond %{THE_REQUEST} /babycare/testimonials\.php\?id=6 [NC] 
RewriteRule^/testimonial/cat/4? [L,R] 
RewriteCond %{THE_REQUEST} /babycare/testimonials\.php\?id=5 [NC] 
RewriteRule^/testimonial/cat/3? [L,R] 
RewriteCond %{THE_REQUEST} /babycare/testimonials\.php\?id=1 [NC] 
RewriteRule^/testimonial/cat/1? [L,R] 

//これは正常に動作している

RewriteCond %{THE_REQUEST} /babycare/testimonials\.php\?id=3 [NC] 
    RewriteRule^/testimonial/cat/2? [L,R] 

    Redirect 301 /testimonials.php /testimonial 
+0

しかし、私はww.example.com/babycare/general_helpからwww.example.com/articleにリダイレクトしたいと思っています。上記のルールを了解してください。 –

答えて

0

次のようなもの:

RewriteRule ^/article/category/([0-9]+)$ /babycare/general_help/category.php?id=$1 [L] 
+0

もう一度解決してください。 –

+0

あなたは何を試してみましたか?その行をペーストしてコピーしただけではありませんでしたか?あなたはあなたの必要条件を微調整しようとしましたか? – Stuart

0

使用この:

RewriteEngine On 
RewriteRule ^article/category/([^/]*)$ /babycare/general_help/category.php?id=$1 [L] 

は、それはあなたのURL与える:www.example.com/article/category/12

0

私は、これはから私をリダイレクトし、これが今の私

RewriteCond %{THE_REQUEST} /babycare/general_help/category\.php\?id=([0-9]+) [NC] 
RewriteRule^/article/category/%1? [L,R] 

のために働いているエラーを得たのwww.example.com/babycare/general_help/category.php?id=12www.example.com/article/category/12

+0

しかし、私はこれをリダイレクトしたいと思うし、www.example.com/babycare/general_helpからwww.example.com/articleに矛盾しています。 –