Add a directory structure to the url, how to write 301 redirection rules for the .htaccess file?
大海潮涌
大海潮涌 2017-09-19 14:41:54
0
3
1448

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


大海潮涌
大海潮涌

学习,学习,学习!

reply all(3)
那山

 thinkphp

Ty80

It is recommended to use php’s 301 jump

Header("HTTP/1.1 301 Moved Permanently");
Header("Location: //m.sbmmt.com".$_SERVER["REQUEST_URI"]);
exit;


  • reply 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
    大海潮涌 author 2017-09-19 18:55:27
小小卫
娶回家我的表情屋都比都不会1笔UIu32b32b2ibf2iuffn我请你点击暖气内勤入侵群人UI完全纳入刘清华人u3qhrh三好厌i三群人很好奇和日期和其如何去武汉李红日


  • reply Brush P beans, right?
    PHP中文网 author 2017-09-19 16:36:33
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template