【发布时间】:2016-01-19 20:55:46
【问题描述】:
我在使用自定义 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 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
非常感谢您的帮助。
【问题讨论】: