重定向的.htaccess只​​网址中包含月底号

编程入门 行业动态 更新时间:2024-10-25 18:22:55
本文介绍了重定向的.htaccess只​​网址中包含月底号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要重定向的URL每包含端子号:

example/773到blog.example/773

而不是重定向的URL包含这样的字符串:

example/web或example/web/shop或example/about

我使用这个htaccess的code:

< IfModule mod_rewrite.c>RewriteEngine叙述在的RewriteCond%{REQUEST_URI} ^ / [0-9]重写规则(。*)blog.example/$1 [R = 301,L]< / IfModule>

但这种htaccess的code重定向的URL是这样的:

example/773到blog.example/blog/773

解决方案

下面的规则将只重定向这类URL的只有: example/773 。如果URL就会像 example/somfolder/773 (与路径中的一些文件夹),那么什么都不会发生了。

RewriteEngine叙述在的RewriteBase /重写规则^(\\ d +)$ blog.example/$1 [R = 301,L]

I want to redirect every URLs contain number at end to subdomain :

example/773 to blog.example/773

and not redirect URLs contain strings like this :

example/web or example/web/shop or example/about

i used this htaccess code :

<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI} ^/[0-9] RewriteRule (.*) blog.example/$1 [R=301,L] </IfModule>

but this htaccess code redirect URLs like this :

example/773 to blog.example/blog/773

解决方案

The rule below will redirect ONLY this sort of URLs only: example/773. If URL will be like example/somfolder/773 (with some folder in the path) then nothing will happened.

RewriteEngine On RewriteBase / RewriteRule ^(\d+)$ blog.example/$1 [R=301,L]

更多推荐

重定向的.htaccess只​​网址中包含月底号

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

发布评论

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

>www.elefans.com

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