重写规则在.htaccess中有效,不在另一个包含的文件中吗?
我有一个带有Magento和Wordpress的服务器 Magento位于网站根目录重写规则在.htaccess中有效,不在另一个包含的文件中吗?,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我有一个带有Magento和Wordpress的服务器 Magento位于网站根目录/,Wordpress位于/blog/下 在网站根目录的文件中指定了各种重定向301和重定向匹配永久。此文件是从Apache vhost配置中“包含”的: Include /var/www/html/myredirects Wordpress中的一些页面应该在网站根目录中可见,以便 http://www.mymagento.com/pretty-url/ 将显示与相同的内容 http://www.mymag
/
,Wordpress位于/blog/
下
在网站根目录的文件中指定了各种重定向301
和重定向匹配永久
。此文件是从Apache vhost配置中“包含”的:
Include /var/www/html/myredirects
Wordpress中的一些页面应该在网站根目录中可见,以便
http://www.mymagento.com/pretty-url/
将显示与相同的内容
http://www.mymagento.com/blog/pretty-url/
这是目前在.htaccess
文件中使用以下重写实现的:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^pretty-url/ /blog/pretty-url/ [L]
[...more like the above here and the common Magento rewrites follow...]
RewriteRule ^api/rest api.php?type=rest [QSA,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^index.php
RewriteCond %{REQUEST_URI} !\.(html|jpg|png|gif)$
RewriteCond %{HTTP:X-Requested-With} !=XMLHttpRequest
RewriteRule ^(.*)$ %{REQUEST_URI}/ [L,R=301]
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</IfModule>
在这两种情况下,它都不起作用,结果要么是空白页,要么是服务器错误
我在Apache文档中找不到为什么.htaccess
中定义的任何东西都可以工作的原因。也许是因为加工订单
编辑,如被问及myredirects
的外观(请注意,这些重定向已经起作用了):
它们是一组不同于Magento的产品类别的URL,加上一些与/blog/
相关的URL,它们看起来都是这样的:
# These are Magento
RedirectMatch permanent /product-category/sub-category-1/sub-category-2/(colorA|colorB|colorC) /sub-category-2/$1
Redirect 301 /someurl/otherurl/ /another/url
# These are for Wordpress
Redirect 301 /blog/tag/some-tag/ /blog/some-tag/
Redirect 301 /blog/tag/another-tag/ /blog/another-tag/
这些博客只重定向了/tag/
部分,没有其他内容
是的,只有一些
/blog/
URL也应该显示在网站根目录下,其他URL将保留在/blog/
下(我知道在两个路径中显示的URL会有重复内容)。myredirects文件看起来像什么?是的,显示MyDirectors,如果不了解实际使用的内容,就无法调试apache内容。实际上,您并不是为了跳过/blog/部分而为每个漂亮的url输入文字url,是吗?这是一个相当严重的错误,除非它只是针对几个页面,您希望重写规则按预期“正常工作”,即,一组用于/blog/另一组用于另一组。内部apache规则的语法与.htaccess规则稍有不同,尤其是在配置文件中,它们的路径htaccess不是以/开头的。我想。选择一个,htaccess或myredirects。myredirects文件是什么样子的?是的,显示mydirects,如果不查看实际使用的内容,就无法调试apache内容。实际上,您并不是为了跳过/blog/部分而为每个漂亮的url输入文字url,是吗?这是一个相当严重的错误,除非它只是针对几个页面,您希望重写规则按预期“正常工作”,即,一组用于/blog/另一组用于另一组。内部apache规则的语法与.htaccess规则稍有不同,尤其是在配置文件中,它们的路径htaccess不是以/开头的。我想。选择一个,htaccess或myredirects。
# These are Magento
RedirectMatch permanent /product-category/sub-category-1/sub-category-2/(colorA|colorB|colorC) /sub-category-2/$1
Redirect 301 /someurl/otherurl/ /another/url
# These are for Wordpress
Redirect 301 /blog/tag/some-tag/ /blog/some-tag/
Redirect 301 /blog/tag/another-tag/ /blog/another-tag/