htaccess从旧网址重定向到新网址

编程入门 行业动态 更新时间:2024-10-22 02:43:16
本文介绍了htaccess从旧网址重定向到新网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试从htaccess中的旧网址重定向到新网址,这是我的代码/尝试/尝试,没有任何运气.

I am trying to redirect from old url to new url in htaccess and here is my code/try/attempts without any luck.

旧网址- www.rosterelf/blog/why-i-always-hire-for-attitude-over-skill-通常

新网址- www.rosterelf/blog/why-i-always-hire-attitude-over-skill-usually

.htaccess 代码尝试1

RedirectMatch 301 ^/blog/为什么我总是会在技术上占主导地位,/blog/为什么总是会在技术上在态度占主导地位

我还有另外301个重定向,但即使我评论了这些重定向,上述条件也不起作用,因此请相信其他条件没有错.

I have couple of other 301 redirects but even if I comment those, above condition does not work so believe others conditions are not in fault.

这是我完整的 htaccess 代码.

<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On ## ## You may need to uncomment the following line for some hosting environments, ## if you have installed to a subdirectory, enter the name here also. ## # RewriteBase / ## ## Uncomment following lines to force HTTPS. ## # RewriteCond %{HTTPS} off # RewriteRule (.*) %{SERVER_NAME}/$1 [L,R=301] ## ## Allow robots.txt ## RewriteRule ^robots.txt - [L] ## 301 redirect for old support details page url to new one ## OLD URL www.rosterelf/support-detail/1903/how-can-employees-clock-inout-of-time-clock-different-slug ## NEW URL www.rosterelf/support-detail/how-can-employees-clock-inout-of-time-clock-different-slug RewriteRule ^(support-detail)/\d+/([\w-]+)/?$ /$1/$2 [R=301,NC,L] RewriteRule ^blog-detail/\d+/([\w-]+)/?$ /blog/$1 [R=301,NC,L] RedirectMatch 301 ^/blog/why-i-always-hire-for-attitude-over-skill-usually /blog/why-i-always-hire-attitude-over-skill-usually ## ## Black listed folders ## RewriteRule ^bootstrap/.* index.php [L,NC] RewriteRule ^config/.* index.php [L,NC] RewriteRule ^vendor/.* index.php [L,NC] RewriteRule ^storage/cms/.* index.php [L,NC] RewriteRule ^storage/logs/.* index.php [L,NC] RewriteRule ^storage/framework/.* index.php [L,NC] RewriteRule ^storage/temp/protected/.* index.php [L,NC] RewriteRule ^storage/app/uploads/protected/.* index.php [L,NC] ## ## White listed folders ## RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} !/.well-known/* RewriteCond %{REQUEST_FILENAME} !/storage/app/uploads/public/.* RewriteCond %{REQUEST_FILENAME} !/storage/app/media/.* RewriteCond %{REQUEST_FILENAME} !/storage/app/resized/.* RewriteCond %{REQUEST_FILENAME} !/storage/temp/public/.* RewriteCond %{REQUEST_FILENAME} !/themes/.*/(assets|resources)/.* RewriteCond %{REQUEST_FILENAME} !/plugins/.*/(assets|resources)/.* RewriteCond %{REQUEST_FILENAME} !/modules/.*/(assets|resources)/.* RewriteRule !^index.php index.php [L,NC] ## ## Block all PHP files, except index ## RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} \.php$ RewriteRule !^index.php index.php [L,NC] ## ## Standard routes ## RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>

有人可以指导我该怎么做.

Can someone guide me what should I do to achieve this.

谢谢

推荐答案

根据您显示的示例,可以请尝试以下操作.

Based on your shown samples, could you please try following.

<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine ON ## ## You may need to uncomment the following line for some hosting environments, ## if you have installed to a subdirectory, enter the name here also. ## # RewriteBase / ## ## Uncomment following lines to force HTTPS. ## # RewriteCond %{HTTPS} off # RewriteRule (.*) %{SERVER_NAME}/$1 [L,R=301] ## ## Allow robots.txt ## RewriteRule ^robots.txt - [NC,L] ## 301 redirect for old support details page url to new one ## OLD URL www.rosterelf/support-detail/1903/how-can-employees-clock-inout-of-time-clock-different-slug ## NEW URL www.rosterelf/support-detail/how-can-employees-clock-inout-of-time-clock-different-slug RewriteRule ^(support-detail)/\d+/([\w-]+)/?$ /$1/$2 [R=301,NC,L] RewriteRule ^blog-detail/\d+/([\w-]+)/?$ /blog/$1 [R=301,NC,L] RewriteRule ^blog/why-i-always-hire-for-attitude-over-skill-usually /blog/why-i-always-hire-attitude-over-skill-usually [R=301,NC,L] ## ## Black listed folders ## RewriteRule ^(?:bootstrap|config|vendor|storage/(?:cms|logs|framework|temp/protected|app/uploads/protected))/ index.php [L,NC] ## ## White listed folders ## RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} !/.well-known/* RewriteCond %{REQUEST_FILENAME} !/storage/app/uploads/public/.* RewriteCond %{REQUEST_FILENAME} !/storage/app/media/.* RewriteCond %{REQUEST_FILENAME} !/storage/app/resized/.* RewriteCond %{REQUEST_FILENAME} !/storage/temp/public/.* RewriteCond %{REQUEST_FILENAME} !/themes/.*/(assets|resources)/.* RewriteCond %{REQUEST_FILENAME} !/plugins/.*/(assets|resources)/.* RewriteCond %{REQUEST_FILENAME} !/modules/.*/(assets|resources)/.* RewriteRule !^index\.php index.php [L,NC] ## ## Block all PHP files, except index ## RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} \.php$ RewriteRule !^index\.php index.php [L,NC] ## ## Standard routes ## RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>

更多推荐

htaccess从旧网址重定向到新网址

本文发布于:2023-10-12 16:59:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485321.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网址   到新   重定向   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!