htaccess希望在不影响子域的情况下添加www

时间:2015-07-26 17:18:54

标签: php apache .htaccess mod-rewrite cpanel

这就是我在htaccess中所拥有的,我的所有其他页面都显示404错误,主页有效,但没有添加www。

<IfModule mod_rewrite.c>
RewriteEngine On

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1[R=301,L]
</IfModule>

Live site link

任何帮助表示赞赏!我疯了:)

1 个答案:

答案 0 :(得分:0)

这应该适合你:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^macmetro\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]