[英]Writing .htaccess file in Ubuntu
我有一個域名http://www.mydomain.com
。 我的根文件夾結構是這樣的。
根
-WordPress
我想將所有請求重定向到wordpress文件夾。 我用谷歌搜索並寫了這樣的文件
RewriteEngine on
rewritecond %{http_host} http://mydomain.com/ [nc]
rewriterule (.*)$ http://mydomain.com/wordpress [r=301,nc]
我現在收到404 File not found錯誤。 我什至嘗試使用另一種技術來創建索引文件並使用header('location:/wordpress1)
,效果很好,但是每當我在Wordpress中上載主題時,它就會給我500 Internal srver Error ..任何可以幫助我的人注意:我正在標記php,因為他們可能會使用此文件
HTTP_HOST變量包含客戶端向其發出HTTP請求的服務器名稱。 在您的情況下為mydomain.com。 當前條件永遠不會匹配。 重寫主機並重定向到子目錄是不同的問題。
RewriteEngine on
RewriteBase /
# This will redirect mydomain.com URIs to www.mydomain.com
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^.*$ http://www.mydomain.com/$0 [R=301,L]
# This will do an INTERNAL redirect to the wordpress folder
RewriteCond $0 !^wordpress/
RewriteRule ^.*$ wordpress/$0
第二條規則的條件是防止內部重定向循環。 $ 0設置為“整個匹配字符串”。
同時刪除索引文件和位置。 這是一種無效的語法,對新手來說,它具有各種各樣的副作用。
嘗試
RewriteEngine on
RewriteCond $1 !^(index\.php|wordpress/wp_content)
RewriteRule ^(.*)$ /wordpress/index.php/$1 [L]
第二行是例外。 您可能需要添加更多內容以包含html需要包含的文件夾。
RewriteCond $ 0!^ wordpress / RewriteRule ^。* $ wordpress / $ 0這是最好的方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.