使用包含特定号码的网址重定向到索引
16lz
2021-01-22
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
更多相关文章
- 如何让Netbeans调试器暂停每个新的php文件执行?
- 如何使用PHP读取.xls文件(Excel) ?
- 解决Apache2+PHP上传文件大小限制的问题技术集锦
- 上传文件时通过AJAX更新列表
- 如何防止.htaccess重定向中的一个文件?
- 使用mod_rewrite将文件夹转换为查询字符串
- PHP上传文件 Error 6解决方法
- 使用.php文件生成一个MySQL转储文件。
- thinkPHP5下扩展encryptedData解密算法文件的注意事项