Php 重定向到包含特定编号的url的索引
我对自定义Wordpress htaccess文件有一些问题。我想从包含域后数字的所有URL获得简单重定向,例如:Php 重定向到包含特定编号的url的索引,php,wordpress,.htaccess,Php,Wordpress,.htaccess,我对自定义Wordpress htaccess文件有一些问题。我想从包含域后数字的所有URL获得简单重定向,例如: http://example.com/123 -> to http://example.com 我的第二个问题几乎是一样的,但对于1个特定的4字母URL,例如: http://example.com/4554 -> to http://example.com/ but http://example.com/4555 (other 4-letter nubmer sho
http://example.com/123 -> to http://example.com
我的第二个问题几乎是一样的,但对于1个特定的4字母URL,例如:
http://example.com/4554 -> to http://example.com/
but http://example.com/4555 (other 4-letter nubmer should fail)
我已经尝试了很多东西,例如:
RewriteRule ^[0-9]{3}$ http://example.com [R=301,L]
但它不起作用。
常用Wordpress htaccess文件:
# 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
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
非常感谢您的帮助。您可以使用:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(\d{3}|4554)/?$ / [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#开始WordPress
重新启动发动机
重写基/
重写规则^(\d{3}| 4554)/?$/[R=301,L]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
嗯,这比我想象的要容易。谢谢