我想在我的.htaccess文件中创建以下结构:
如果(站点的域或站点的子域){
重写这个特定的方式 - > /index.php/$1
} 其他 {
重写这个特定的方式 - > /directory/www/index.php/$1
}
我有我目前的code以下,但它扔500S跟我抱怨Apache的错误日志:
[错误] [客户:: 1] mod_rewrite的:达到内部重定向的最大数量。假设配置错误。使用RewriteOptions MaxRedirects'增加,如果neccessary极限,引用者:
我是什么做错了吗?谢谢!
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
!的RewriteCond $ l ^(指数 .PHP |博客)
的RewriteCond%{HTTP_HOST} ^子域 .EXAMPLE .COM $ [NC,OR]
的RewriteCond%{HTTP_HOST} ^例如 .COM $
重写规则? - [S = 1]
重写规则^(。*)$ /directory/www/index.php/$1 [L]
重写规则? - [S = 1]
重写规则^(。*)$ /index.php/$1 [L]
解决方案
这可能是一个小吸尘器只包含/排除使用条件下比跳越标志(可以得到的那种混乱阅读)。但它看起来像有一个重定向循环导致500试试这个:
#如果(站点的域或站点的子域)
的RewriteCond%{HTTP_HOST} ^子域 .EXAMPLE .COM $ [NC,OR]
的RewriteCond%{HTTP_HOST} ^例如 .COM $ [NC]
#确保我们尚未改写此URI
的RewriteCond%{REQUEST_URI}!/directory/www/index.php
#如果资源已经存在,不重写
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
# 改写
重写规则^(。*)$ /directory/www/index.php/$1 [L]
#如果!(站点的域或站点的子域)
的RewriteCond%{HTTP_HOST}!^子域 .EXAMPLE .COM $ [NC]
的RewriteCond%{HTTP_HOST}!^例如 .COM $ [NC]
#确保我们尚未改写此URI
的RewriteCond%{REQUEST_URI}!的index.php
#如果资源已经存在,不重写
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
# 改写
重写规则^(。*)$ /index.php/$1 [L]
I want to create the following structure in my .htaccess file:
If (SITE A DOMAIN or SITE A SUBDOMAIN) {
Rewrite this specific way -> /index.php/$1
} else {
Rewrite this specific way -> /directory/www/index.php/$1
}
I have my current code below, but it's throwing 500s with my Apache error logs whining about:
[error] [client ::1] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary., referer:
What am I doing wrong? Thanks!
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index.php|blog)
RewriteCond %{HTTP_HOST} ^subdomain.example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^ example.com$
RewriteRule .? - [S=1]
RewriteRule ^(.*)$ /directory/www/index.php/$1 [L]
RewriteRule .? - [S=1]
RewriteRule ^(.*)$ /index.php/$1 [L]
解决方案
It may be a little cleaner to just include/exclude using conditions than the skip flags (which can get kind of confusing to read). But it looks like there's a redirect loop causing the 500. Try this:
# If (SITE A DOMAIN or SITE A SUBDOMAIN)
RewriteCond %{HTTP_HOST} ^subdomain.example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
# make sure we haven't already rewritten this URI
RewriteCond %{REQUEST_URI} !/directory/www/index.php
# don't rewrite if the resource already exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# rewrite
RewriteRule ^(.*)$ /directory/www/index.php/$1 [L]
# IF !(SITE A DOMAIN or SITE A SUBDOMAIN)
RewriteCond %{HTTP_HOST} !^subdomain.example.com$ [NC]
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
# make sure we haven't already rewritten this URI
RewriteCond %{REQUEST_URI} !/index.php
# don't rewrite if the resource already exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# rewrite
RewriteRule ^(.*)$ /index.php/$1 [L]