I have some problems with custom Wordpress htaccess file. I want to get simple redirection from all URLs containing numbers after domain, ex:

我有自定义Wordpress htaccess文件的一些问题。我想从域之后的所有包含数字的URL中获得简单的重定向,例如:

http://example.com/123 -> to http://example.com

And, my second problem is almost the same, but for 1 specific 4-letter URL, ex:

而且,我的第二个问题几乎相同,但对于1个特定的4个字母的URL,例如:

http://example.com/4554 -> to http://example.com/
but http://example.com/4555 (other 4-letter nubmer should fail)

I've already tried many things, for example:

我已经尝试了很多东西,例如:

RewriteRule ^[0-9]{3}$ http://example.com [R=301,L]

But it doesnt work. Usual Wordpress htaccess file:

但它不起作用。通常的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

Many thanks for help.

非常感谢你的帮助。

1 个解决方案

#1


1

You can use:

您可以使用:

# 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

更多相关文章

  1. 如何让Netbeans调试器暂停每个新的php文件执行?
  2. 如何使用PHP读取.xls文件(Excel) ?
  3. 解决Apache2+PHP上传文件大小限制的问题技术集锦
  4. 上传文件时通过AJAX更新列表
  5. 如何防止.htaccess重定向中的一个文件?
  6. 使用mod_rewrite将文件夹转换为查询字符串
  7. PHP上传文件 Error 6解决方法
  8. 使用.php文件生成一个MySQL转储文件。
  9. thinkPHP5下扩展encryptedData解密算法文件的注意事项

随机推荐

  1. android databinding 学习开篇
  2. Android培训班(53)
  3. android 5.1 添加reboot 飞行模式 silent
  4. Android - 组件工具箱(widget tool box)
  5. Android 起步 环境配置 持续更新
  6. Android平台开发-WIFI 驱动移植 -- 详细
  7. Android杂谈--小知识点总结(1)
  8. Android如何判断是否是平板
  9. 【转】android 有效解决achartengine在sc
  10. Android 获取地理位置的经度和纬度