htaccess的 - 不会增加WWW只有一个子目录
我在根目录下的.htaccess,与此内容:
I have a .htaccess in root directory, with this content:
<IfModule mod_rewrite.c>
RewriteEngine on
#RewriteCond %{HTTP_HOST} ^domain.com
#RewriteRule (.*) http://www.domain.com$1 [R=301,L]
</IfModule>
如果我去 http://domain.com/subdir 它改写到的 http://www.domain.com/subdir
不过,我有一个名为客户关系管理一子目录一个问题 - 如果我去 http://domain.com/crm 它重定向我 http://www.domain.com 代替的 http://www.domain.com/crm
But I have a problem with one subdirectory named "crm" - if I go to http://domain.com/crm it redirects me to http://www.domain.com instead of http://www.domain.com/crm.
在此客户关系管理的子目录我有另外一个.htaccess文件,它重写PHP扩展为.html。这里是code:
In this "crm" subdirectory I have another .htaccess file, which rewrites .php extension to .html. Here is the code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([^/]*)/([^/]*)\.html$ ?name=$1&id=$2 [L]
RewriteRule ^(.*).html$ index.php?name=$1 [QSA]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^([^/]*)/([^/]*)\.html$ ?name=$1&id=$2 [L]
</IfModule>
有人能告诉我怎样才能使这项工作?所以,当我会去 http://domain.com/crm 将重定向我的 http://www.domain.com/crm 。
编辑:
根的.htaccess是好的,我改变什么,忘了删除评论的计算器。
Root .htaccess was ok, I was changing something and forgot to remove comments for stackoverflow.
CRM /的.htaccess现在是:
crm/.htaccess is now:
RewriteEngine on
RewriteOptions Inherit
RewriteRule ^([^/]*)/([^/]*)\.html$ ?name=$1&id=$2 [L]
RewriteRule ^(.*).html$ index.php?name=$1 [QSA]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^([^/]*)/([^/]*)\.html$ ?name=$1&id=$2 [L]
但它仍然不重定向这个子目录来www.domain.com/crm~~V但只www.domain.com :(
But it still doesn't redirect this subdir to www.domain.com/crm but only to www.domain.com :(
第一个变化根的.htaccess
这样:(似乎在present进行评论)
First change root .htaccess
to this: (seems to be commented at present)
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
然后在CRM / .htacess加入这一行下方 RewriteEngine叙述上
:
RewriteOptions Inherit
更新:您 CRM /的.htaccess
出现故障。替换内容与code从如下:
UPDATE: Your crm/.htaccess
is faulty. Replace that content with code from below:
RewriteEngine on
RewriteOptions Inherit
RewriteRule ^([^/]*)/([^/]*)\.html$ ?name=$1&id=$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)\.html$ index.php?name=$1 [QSA,L]
在此code是有重定向会发生预期。
Once this code is there redirect will happen as expected.