htaccess规则不起作用

时间:2013-04-04 16:22:43

标签: wordpress .htaccess http mod-rewrite

我在www.marcou.it/wp上安装了WordPress,我将其设置为默认目录。因此,如果我输入marcou.it,浏览器必须向我显示WordPress。

我已经设定了这些规则:

RewriteEngine On #Created by aruba. Do not touch this file!
#ATTENTION: Remove file index.(php|html|htm)
RewriteCond %{REQUEST_URI} !^/wp
RewriteRule ^(.*)$ wp/$1 [L]

但如果我继续www.marcou.it,我就会回复:

  

未找到

     

在此服务器上找不到请求的URL /wp/index.htm。

有什么问题?

3 个答案:

答案 0 :(得分:0)

如果要重定向不在/wp/子目录中的任何内容,可以使用以下内容直接重定向到此,然后根据需要删除index.htmindex.htm可能会被附加为默认文档。

RewriteEngine On
RewriteBase /
RewriteRule ^((?!wp/).*) wp/$1 [R]
RewriteRule ^wp/index.htm$ wp/ [R,L]

您可以在此处测试这些规则(确保您的测试网址包含“http://”):http://htaccess.madewithlove.be/

答案 1 :(得分:0)

只需删除您在此问题上提到的所有代码,因为它不对,请在.htaccess文件中尝试此代码:

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REQUEST_URI} ^/wp/?
RewriteRule ^(.*) /$1

现在试试这个:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^/? /wp
RewriteRule ^(.+)? /wp/$1

如果这不起作用,请尝试删除Options +FollowSymlinks并再次检查!

答案 2 :(得分:0)

RewriteEngine On #created by aruba do not touch this file!
#ATTENTION: Remove file index.(php|html|htm)
RewriteCond %{REQUEST_URI} !^/wp
RewriteRule ^(.*)$ wp/ [L]

# BEGIN WordPress

# END WordPress