301 RedirectMatch - 许多网址网址、RedirectMatch

由网友(月亮是我磨弯滴ㄨ)分享简介:我有以下的htaccess code的地方:选项+了FollowSymLinks< IfModule mod_rewrite.c>RewriteEngine叙述上的RewriteBase /RedirectMatch 301 ^ /([^ ​​- ] +) - ([^ ​​- ] +) - ([^...

我有以下的htaccess code的地方:

 选项+了FollowSymLinks

< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /

RedirectMatch 301 ^ /([^  ​​- ] +) - ([^  ​​- ] +) - ([^  ​​- ] +) - ([^  ​​- ] {2})。的HTML / $ 1- $ 2- IN- $ -3- $ 4.html
RedirectMatch 301 ^ /([^  ​​- ] +) - ([^  ​​- ] +) - ([^  ​​- ] +)。的html $ /$1-$2-in-$3.html

#BEGIN字preSS
重写规则^指数 .PHP $  -  [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。的index.php [L]
< / IfModule>
#结束字preSS
 

我想自动重定向页面,包括中每个新的URL结构。这两个RedirectMatch行上述两种情况下工作,但我需要一个第三个场景是可能的。

首先RedirectMatch线适用于城市(单名):

domain.com/music-classes-dallas-tx.html ===> domain.com/music-classes-in-dallas-tx.html

二RedirectMatch线工程状态:

domain.com/music-classes-texas.html ===> domain.com/music-classes-in-texas.html

我现在需要的是为RedirectMatch与有2-3个字城市名称的工作。例如,菌落TX或新奥尔良LA。在code以上不捕获这些。

有人告诉我用下面的,但它造成了重定向循环,并抛出了一堆的功能于在入入入入到URL。

  RedirectMatch 301 ^ /([^  ​​- ] +) - ([^  ​​- ] +) - (+) - ([^  ​​- ] {2})。 HTML $ /$1-$2-in-$3-$4.html
 

解决方案 win7怎么用资源管理器查qq ip地址呢 要是出现了很多个怎么办

您可以使用这些重写规则尝试。这个测试对我来说,在名称中有空格。并确保尝试之前清除缓存。

 重写规则^([^  ​​- ] +) - ([^  ​​- ] +) - (?!中)([^ /] +) - ([^  ​​- ] {2 })。HTML $ /$1-$2-in-$3-$4.html [R = 301,L]
重写规则^([^  ​​- ] +) - ([^  ​​- ] +) - (?!中)([^  ​​- ] +)。 HTML $ /$1-$2-in-$3.html [R = 301,L ]
 

通过该规则这对我的作品。

  http://example.com/music-classes-dallas-tx.html
 

  http://example.com/music-classes-san-antonio-tx.html
 

I have the below htaccess code in place:

Options +FollowSymLinks

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RedirectMatch 301 ^/([^-]+)-([^-]+)-([^-]+)-([^-]{2}).html$ /$1-$2-in-$3-$4.html
RedirectMatch 301 ^/([^-]+)-([^-]+)-([^-]+).html$ /$1-$2-in-$3.html

# BEGIN WordPress
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

I am trying to automatically redirect pages to include 'in' per the new URL structure. The two RedirectMatch lines above work for two scenarios, but I need a third scenario to be possible.

First RedirectMatch line works for cities (single name):

domain.com/music-classes-dallas-tx.html ===> domain.com/music-classes-in-dallas-tx.html

Second RedirectMatch line works for states:

domain.com/music-classes-texas.html ===> domain.com/music-classes-in-texas.html

What I now need is for the RedirectMatch to work with city names that have 2-3 words. For example, The Colony TX or New Orleans LA. The code above doesn't catch these.

Someone told me to use the below, but it's causing a redirect loop and throws in a bunch of in-in-in-in-in-in-in into the URL.

RedirectMatch 301 ^/([^-]+)-([^-]+)-(.+)-([^-]{2}).html$ /$1-$2-in-$3-$4.html

解决方案

Can you try it with these rewrite rules. This tested out for me with a space in the name. And make sure to clear your cache before trying them.

RewriteRule ^([^-]+)-([^-]+)-(?!in)([^/]+)-([^-]{2}).html$ /$1-$2-in-$3-$4.html [R=301,L]
RewriteRule ^([^-]+)-([^-]+)-(?!in)([^-]+).html$ /$1-$2-in-$3.html [R=301,L]

With that rule this works for me.

http://example.com/music-classes-dallas-tx.html

or

http://example.com/music-classes-san-antonio-tx.html

阅读全文

相关推荐

最新文章