Apache .htaccess-冲突规则导致内部服务器错误
我打算在我们的网站上添加一个部分,该部分主要由.htaccess文件提供支持 目前,我有一个规则,如果域后只有一个部分,则可以处理重写,因此类似以下内容将导致站点搜索名为“theteam”的页面 这很有效,但我现在尝试添加一个部分,该部分将具有以下地址: 问题是,当我为此添加一个规则(确保它高于以前的规则)时,它会导致500个内部服务器错误。如果我有一条规则或另一条规则,它可以完美地工作,但当两条规则都存在时,问题就来了 这有点难以解释,因此问题代码如下:Apache .htaccess-冲突规则导致内部服务器错误,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我打算在我们的网站上添加一个部分,该部分主要由.htaccess文件提供支持 目前,我有一个规则,如果域后只有一个部分,则可以处理重写,因此类似以下内容将导致站点搜索名为“theteam”的页面 这很有效,但我现在尝试添加一个部分,该部分将具有以下地址: 问题是,当我为此添加一个规则(确保它高于以前的规则)时,它会导致500个内部服务器错误。如果我有一条规则或另一条规则,它可以完美地工作,但当两条规则都存在时,问题就来了 这有点难以解释,因此问题代码如下: RewriteRule ^prod
RewriteRule ^products/?$ ?cat=top-level-summary&page=products [QSA]
RewriteRule ^([^/]+)/?$ /?cat=generic&page=$1 [QSA]
以及完整的.htaccess文件:
# Error Handling
ErrorDocument 403 /index.php?cat=error&page=403
ErrorDocument 404 /index.php?cat=error&page=404
ErrorDocument 500 /index.php?cat=error&page=500
ErrorDocument 503 ?cat=error&page=503
# For security reasons, Option followsymlinks cannot be overridden
Options +FollowSymLinks +SymLinksIfOwnerMatch - indexes -MultiViews
# Turn the rewrite engine on
RewriteEngine On
# Set the root of the folder to structure
ReWriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# Start the mod re-write conditions
# Redirect short URLs
RewriteRule ^broadleaf/?$ /products/desktops/broadleaf-one [R=301]
RewriteRule ^broadleafone/?$ /products/desktops/broadleaf-one [R=301]
RewriteRule ^broadleaf-one/?$ /products/desktops/broadleaf-one [R=301]
RewriteRule ^flex/?$ /products/desktops/flex [R=301]
RewriteRule ^fmq/?$ /fixmequick [R=301]
RewriteRule ^warranty/?$ /productregistration [R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Redirect the specific categories
RewriteRule ^products/?$ ?cat=top-level-summary&page=products [QSA]
RewriteRule ^([^/]+)/?$ /?cat=generic&page=$1 [QSA]
RewriteRule ^products/([^/]+)/([^/]+)$ ?cat=product&page=$2 [QSA]
RewriteRule ^products/([^/]+)/?$ /?cat=product-section-summary&page=$1 [QSA]
# Redirects for blog
RewriteRule ^blog/([^/]+)$ ?cat=blog&page=$1
RewriteRule ^blog/category/([^/]+)$ ?cat=blog_archive_or_category&blog_cat=$1
RewriteRule ^blog/archive/([^/]+)/([^/]+)$ ?cat=blog_archive_or_category&year=$1&month=$2
# Redirect the browser to the https:// version of the domain
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]
# Disable hot-linking of files on the server
# (other sites cannot link to our images and steal our bandwidth)
RewriteCond %{HTTP_REFERER} !^$
#RewriteCond %{HTTP_REFERER} !very-pc\.co\.uk [NC]
RewriteCond %{HTTP_REFERER} !verypc\.very-dev\.co\.uk [NC]
RewriteCond %{HTTP_REFERER} ^http://(cms\.)?very-pc\.co\.uk/ [OR]
RewriteCond %{HTTP_REFERER} ^http://(cms\.)?very-dev\.co\.uk/ [NC]
RewriteRule \.(gif|jpg|png|pdf)$ - [F,NC]
# Redirect to remove /index.php and /index.html files
RewriteCond %{THE_REQUEST} \ /(.+/)?index\.(php|html)(\?.*)?\ [NC]
RewriteRule ^(.+/)?index\.(php|html)$ /%1 [NC,R=301,L,QSA]
正如我所说的,我试着让一句话或另一句话出现,这是有效的,所以我最好的猜测是这两条规则在某种程度上是冲突的
我尝试过在参数上乱搞,例如将其更改为重定向或添加[L]以使其在第一行遇到后停止,但我没有运气
任何建议都很好 像这样使用.htaccess:
# Error Handling
ErrorDocument 403 /index.php?cat=error&page=403
ErrorDocument 404 /index.php?cat=error&page=404
ErrorDocument 500 /index.php?cat=error&page=500
ErrorDocument 503 ?cat=error&page=503
# For security reasons, Option followsymlinks cannot be overridden
Options +FollowSymLinks +SymLinksIfOwnerMatch -indexes -MultiViews
# Turn the rewrite engine on
RewriteEngine On
# Set the root of the folder to structure
ReWriteBase /
# Disable hot-linking of files on the server
# (other sites cannot link to our images and steal our bandwidth)
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !verypc\.very-dev\.co\.uk [NC]
RewriteCond %{HTTP_REFERER} ^http://(cms\.)?very-pc\.co\.uk/ [OR]
RewriteCond %{HTTP_REFERER} ^http://(cms\.)?very-dev\.co\.uk/ [NC]
RewriteRule \.(gif|jpg|png|pdf)$ - [F,NC]
# Redirect the browser to the https:// version of the domain
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# Redirect to remove /index.php and /index.html files
RewriteCond %{THE_REQUEST} \s/(.+?/)?index\.(php|html)(\?.*)?\ [NC]
RewriteRule ^(.+/)?index\.(php|html)$ /%1 [NC,R=301,L,NE]
# Start the mod re-write conditions
# Redirect short URLs
RewriteRule ^broadleaf/?$ /products/desktops/broadleaf-one [L,R=301]
RewriteRule ^broadleafone/?$ /products/desktops/broadleaf-one [L,R=301]
RewriteRule ^broadleaf-one/?$ /products/desktops/broadleaf-one [L,R=301]
RewriteRule ^flex/?$ /products/desktops/flex [L,R=301]
RewriteRule ^fmq/?$ /fixmequick [L,R=301]
RewriteRule ^warranty/?$ /productregistration [L,R=301]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# Redirect the specific categories
RewriteRule ^products/?$ ?cat=top-level-summary&page=products [L,QSA]
RewriteRule ^products/([^/]+)/([^/]+)$ ?cat=product&page=$2 [L,QSA]
RewriteRule ^products/([^/]+)/?$ ?cat=product-section-summary&page=$1 [L,QSA]
# Redirects for blog
RewriteRule ^blog/([^/]+)/$ ?cat=blog&page=$1 [L,QSA]
RewriteRule ^blog/category/([^/]+)$ ?cat=blog_archive_or_category&blog_cat=$1 [L,QSA]
RewriteRule ^blog/archive/([^/]+)/([^/]+)$ ?cat=blog_archive_or_category&year=$1&month=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ /?cat=generic&page=$1 [L,QSA]
错误日志中有什么有用的东西吗?[Thu Aug 14 12:24:05 2014][error][client 78.109.178.130]文件不存在:/home/verypcco/public_html/autodiscover-不确定这是否相关?这是一个可怕的问题。htaccess,如果你把它缩小到我可以调查的问题区域,但目前它相当大。@anubhava告诉我吧!它是别人写的,老实说,我对它只有一个实用的知识。不幸的是,我也急于完成这项工作。我已经删除了未使用和不需要的行-任何您可以给予的帮助将不胜感激!好吧,我敢于重新安排规则并修复丢失的指令。见下面我的答案。