How to redirect URLs based on query string?

前端 未结 2 486
有刺的猬
有刺的猬 2020-11-27 07:03

I successfully mass migrated a Wordpress site to Drupal. Unfortunately in Wordpress, the content URL\'s were something like www.example.org/?p=123. My domain is still the

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 07:24

    You may consider use ModRewrite in your htaccess

    
    
    RewriteEngine On
    
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteCond %{QUERY_STRING}     ^p=345$    [NC]
    RewriteRule index.php content/MyNewPage [NC,L,R=301]
    
    
    

    And you also may want to pass the old page id to the new URL concatenated (or maybe by QS?):

    
    
    RewriteEngine On
    
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteCond %{QUERY_STRING}     ^p=(.*)$    [NC]
    RewriteRule index.php content/MyNewPage-%1 [NC,L,R=301]
    
    
    

提交回复
热议问题