我已成功设置我的.htaccess文件,使用
将网站重定向到子文件夹RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain.org$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain.org$
RewriteRule ^(/)?$ subfolder/index.php [L]
所以当我进入我的域名时,它不会显示/subfolder/index.php
但是当我访问我网站上的某个页面时,它将是www.domain.org/subfolder/anotherpage/,我希望www.domain.org/anotherpage /
感谢任何帮助
谢谢
答案 0 :(得分:2)
尝试以下规则:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain.org$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/subfolder/ [NC]
RewriteRule ^(.*)$ /subfolder/$1 [NC,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain.org$ [NC]
RewriteRule ^/?$ /subfolder/index.php [NC,L]
答案 1 :(得分:0)
你试过这个:
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.org[nc]
RewriteRule ^(.*)$ http://www.domain.org/$1 [r=301,nc]
//301 Redirect Entire Directory
RedirectMatch 301 subfolder(.*) //$1