我有2个网站:一个位于公共html文件夹根目录的网站和另一个位于WFM子文件夹中的网站,WFM子文件夹面临一些问题,无法重定向到正确的页面,而不是显示内容在 domain.com.sg/careers 中,它正在重新加载主页。
奇怪的部分是图像,JS和CSS返回200 OK虽然文件包含index.php的内容。通过Google Chrome网络开发者工具进行测试。
domain.com.sg只是一个虚拟网址。
/home/webfire/public_html/.htaccess上的代码
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
IndexIgnore *
Options All -Indexes
IndexOptions +SuppressHTMLPreamble
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com.sg #Not working correctly
RewriteCond %{REQUEST_URI} !^/wfm #Not working correctly
RewriteRule ^(.*)$ /wfm/$1 [L] #Not working correctly
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f #For website located in the public_html folder
RewriteCond %{REQUEST_FILENAME} !-d #For website located in the public_html folder
RewriteRule ^(.*)$ index.php/$1/ [L] #For website located in the public_html folder
RewriteCond %{REQUEST_METHOD} ^PUT$ [OR]
RewriteCond %{REQUEST_METHOD} ^MOVE$
RewriteRule ^/files/(.*)\.php /files/$1.nophp
RewriteCond %{HTTP_REFERER} !^http://domain.com.sg/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://domain.com.sg$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com.sg/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com.sg$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
答案 0 :(得分:1)
试试这段代码:
IndexIgnore *
Options All -Indexes
IndexOptions +SuppressHTMLPreamble
RewriteEngine On
RewriteBase /
# existing rule to block images hot linking
RewriteCond %{HTTP_REFERER} !^http://domain.com.sg/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://domain.com.sg$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com.sg/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com.sg$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
# for subdomain forward to /wfm/
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com\.sg$
RewriteRule ^((?!wfm/).*)$ /wfm/$1 [L,NC]
# existing rule to handle PUT/MOVE reqquest
RewriteCond %{REQUEST_METHOD} ^PUT$ [OR]
RewriteCond %{REQUEST_METHOD} ^MOVE$
RewriteRule ^files/(.*)\.php /files/$1.nophp [L]
# is PHP file exists for given URI then use it
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^.]+)/?$ $1.php [L]
# forward rest to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1/ [L]