【发布时间】:2014-02-21 23:45:19
【问题描述】:
我有一个正则表达式令人头疼的问题,并且真的可以使用了解正则表达式的人的一些建议。我下面的 URL 重写规则将 /blog/customurl 的 URL 请求重写为 /blog/index.php/customurl - 这对于 Wordpress 永久链接非常有用。
Rewrite Engine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/blog/(?!index.php)(?!wp)([^\.]*)$ /blog/index.php/$1 [I]
现在我还需要一个单独的规则,将 /blog 或 /blog/(没有尾随)重写为 /blog/index.php 在不影响现有规则的情况下。现在请求 /blog 或 /blog/ 404,但在地址栏中手动添加 index.php 会拉出博客主页。想法?
仅供参考在这种情况下,我无法使用 /blog/ 中的 .htaccess 设置特定于文件夹的重写规则。我也不能使用 RewriteBase,所以我真的希望有一个解决方案,可以使用正则表达式从根文件夹解决这个问题。
【问题讨论】:
标签: regex wordpress .htaccess mod-rewrite url-rewriting