.htaccess在RegEx不工作时重定向-“未指定输入文件”
我在我的域名上有一个Wordpress博客,它是由不同的网站管理员建立的。所有职位均按此文件结构归档:.htaccess在RegEx不工作时重定向-“未指定输入文件”,regex,.htaccess,redirect,http-status-code-301,Regex,.htaccess,Redirect,Http Status Code 301,我在我的域名上有一个Wordpress博客,它是由不同的网站管理员建立的。所有职位均按此文件结构归档: http://www.example.com/blog/index.php/2012/04/24/name-of-the-post/ 我正试图使用我的.htaccess文件将链接重定向到旧帖子,并将链接重定向到它们的新地址。请注意,此处显示的是相同的URL,但缺少/index.php: 在我的.htaccess文件中,我尝试用以下内容重定向URL: RewriteEngine on Rewr
http://www.example.com/blog/index.php/2012/04/24/name-of-the-post/
我正试图使用我的.htaccess文件将链接重定向到旧帖子,并将链接重定向到它们的新地址。请注意,此处显示的是相同的URL,但缺少/index.php:
在我的.htaccess文件中,我尝试用以下内容重定向URL:
RewriteEngine on
RewriteRule ^blog/index\.php/([A-Za-z0-9-/.]+)$ http://www.example.com/blog/$1 [R=301]
问题:当我在.htaccess文件中使用上述正则表达式时,我得到一个错误,没有指定输入文件。在浏览器中,则不会发生重定向。我做错了什么?我的正则表达式有问题吗?或者我还遗漏了什么?诀窍是我需要在我的博客目录中放置一个.htaccess文件 以下是对我有效的代码:
RewriteEngine On
RewriteRule ^index\.php/(.*)$ $1 [R=301,L,NC]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
你在哪里看到这样的错误?是谁生成的?WordPress还是Apache?请你检查一下Apache的错误日志,看看是否有确切的错误消息。我不知道你的确切意思。它看起来像是从服务器生成的,因为它是一个完全空白的白色窗口,而不是错误消息。我不相信它是由Wordpress生成的。请检查Apache的错误日志-如果它是由Apache生成的,它应该有准确的描述。好的-询问您的托管公司。。但它应该在“日志”部分的“控制面板”中提供给您。。有时也可以通过FTP访问它——通常文件名为error.log。尝试使用更简单的正则表达式进行匹配,如^blog/index\.php/+$,并告诉我们这是否会改变什么
RewriteEngine On
RewriteRule ^index\.php/(.*)$ $1 [R=301,L,NC]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress