我試圖將www.example.org.uk重定向到example.org.uk/subdirectory,然後隱藏該子目錄 - 因此它只在地址欄上顯示www.example.org.uk。如何將根文件夾重定向到子目錄並在GoDaddy上使用.Htaccess隱藏它?
這是我用的是原來的代碼(從https://my.bluehost.com/cgi/help/347):
# BlueHost.com
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.org.uk$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by/then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?example.org.uk$
RewriteRule ^(/)?$ subdirectory/index.php [L]
的問題是,沒有這個代碼的工作。
搜索#1和使用意見後 - 這是當前的代碼:
Options +FollowSymLinks -Multiviews
<IfModule mod_rewrite.c>
# BlueHost.com
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?grampianyoga.org.uk$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/gya2/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /gya2/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by/then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?grampianyoga.org.uk$
RewriteRule ^(/)?$ gya2/index.php [L]</IfModule>
不幸的是顯示一個內部錯誤,這是什麼錯誤文件指出:[Wed Mar 26 14:22:35 2014] [9566783] [core:alert] [client 97.74.104.6:60525] /var/chroot/home/content/83/9566783/html/.htaccess: RewriteRule: bad flag delimiters
我使用GoDaddy的,我相信他們有自己的設置。有沒有人有什麼建議?嘗試支持,顯然他們 無法幫助腳本。
嘗試在感興趣的目錄上方的父目錄中的'.htaccess'中添加以下內容:'RedirectMatch ^/foo/$/foo/bar /'或'RedirectMatch ^/foo/$/bar/baz /' 。另請參閱[如何讓apache2重定向到子目錄](http://serverfault.com/q/9992/145545)。 – jww