本文介绍了重定向的.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/773and not redirect URLs contain strings like this :
example/web or example/web/shop or example/abouti 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只网址中包含月底号
发布评论