search

Home  >  Q&A  >  body text

Add a directory structure to the url, how to write 301 redirection rules for the .htaccess file?

My website is a wordpress website and I want to revise it

The fixed link jumps from http://domain name/%post_id%.html to http://domain name/�tegory%//%post_id%. html

How should I write the 301 redirection rule for the .htaccess file?

The following is the current htaccess file:

# BEGIN WPSuperCache

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible

AddDefaultCharset UTF-8

RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} !.*=.*

RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp- postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"] [NC]

RewriteCond %{HTTP:Profile} ! ^[a-z0-9\"] [NC]

RewriteCond %{HTTP:Accept-Encoding} gzip

RewriteCond %{HTTPS} on

RewriteCond %{ DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{ SERVER_NAME}/$1/index-https.html.gz" [L]


##RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} ! .*=.*

RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile } !^[a-z0-9\"] [NC]

RewriteCond %{HTTP:Profile} !^[a-z0-9\"] [NC]

RewriteCond % {HTTP:Accept-Encoding} gzip

RewriteCond %{HTTPS} !on

RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index. html.gz -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html.gz" [L]


RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} !.*=.*

RewriteCond %{HTTP:Cookie} !^.*(comment_author_ |wordpress_logged_in|wp-postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"] [NC]

RewriteCond %{ HTTP:Profile} !^[a-z0-9\"] [NC]

RewriteCond %{HTTPS} on

RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/ %{SERVER_NAME}/$1/index-https.html -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html" [L ]


RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} !.*=.*

RewriteCond %{HTTP :Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"] [NC]

RewriteCond %{HTTP:Profile} !^[a-z0-9\"] [NC]

RewriteCond %{HTTPS} !on

RewriteCond %{DOCUMENT_ROOT }/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/ index.html" [L]

</IfModule>


END WPSuperCache


# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>


# END WordPress

# BEGIN EWWWIO

# END EWWWIO


大海潮涌大海潮涌2613 days ago1442

reply all(3)I'll reply

  • 那山

    那山2017-09-20 08:15:00

     thinkphp

    reply
    0
  • PHP中文网

    PHP中文网2017-09-19 16:35:58

    It is recommended to use php’s 301 jump

    Header("HTTP/1.1 301 Moved Permanently");
    Header("Location: http://www.php.cn".$_SERVER["REQUEST_URI"]);
    exit;


    reply
    0
  • 大海潮涌

    Thank you for your answer, but visual inspection does not apply. I want to jump from http://domain name/%post_id%.html to http://domain name/%category%/%post_id%.html in batches, adding the directory name in the middle. . For example: http://www.seoshipin.cn/1.html Jump to http://www.seoshipin.cn/seorumen/1.html

    大海潮涌 · 2017-09-19 18:55:27
  • 小小卫

    小小卫2017-09-19 16:11:26

    娶回家我的表情屋都比都不会1笔UIu32b32b2ibf2iuffn我请你点击暖气内勤入侵群人UI完全纳入刘清华人u3qhrh三好厌i三群人很好奇和日期和其如何去武汉李红日


    reply
    0
  • PHP中文网

    Brush P beans, right?

    PHP中文网 · 2017-09-19 16:36:33
  • Cancelreply