简体   繁体   English

Apache Mod重写.htaccess问题

[英]Apache mod rewrite .htaccess problem

My site is a php based site, but I've added wordpress in a /blog/ folder. 我的站点是一个基于php的站点,但是我在/ blog /文件夹中添加了wordpress。 The .htaccess file below should allow the /blog/ folder to be accessed, but I get a 404 error saying that blog.php doesn't exist. 下面的.htaccess文件应允许访问/ blog /文件夹,但出现404错误,提示blog.php不存在。

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{SCRIPT_FILENAME}  !\.(gif|jpg|png)$
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)/(.*)/$ /$1_$2.php [L]
    RewriteRule ^(.*)/$ /$1.php [L]
</IfModule>

Anybody able to help at all? 有人能提供帮助吗?

最后一个RewriteRule将您的请求重定向到/blog/index.php ,您应该添加一个RewriteCond来检查请求是否在博客文件夹中。

RewriteCond %{REQUEST_URI} !^/blog/.*

Adding 新增中

RewriteRule ^(blog) - [L]

to public_html/.htaccess after 到public_html / .htaccess之后

RewriteEngine On

worked for me as well on a fresh Wordpress installation with Fantastico on a Hostgator account, with a blog.example.com subdomain. 我也通过Fantastico在Hostgator帐户(带有blog.example.com子域)上与Fantastico一起全新安装了Wordpress。

I managed this using the code below, for some reason the conditionals that were suggested don't work (I HATE .htaccess) 我使用下面的代码对此进行了管理,由于某些原因,建议的条件不起作用(我讨厌.htaccess)

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^(blog) - [L]
    RewriteCond %{SCRIPT_FILENAME}  !\.(gif|jpg|png)$
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)/(.*)/$ /$1_$2.php [L]
    RewriteRule ^(.*)/$ /$1.php [L]
</IfModule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM