可能重複:
htaccess rewrite breaks relative paths漂亮的URL與htaccess的
我希望有人能幫助我。我正嘗試將我的網站設置爲使用漂亮的網址。
我現在有哪些隱藏包含我所有的php文件我的子域文件夾,以及我從http協議更改爲https,反之亦然命令幾個htaccess的命令。漂亮的網址被證明是困難的。我想完全通過htaccess而不是php。我設法寫了一個可以工作的命令,但是之後我的CSS或JavaScript沒有工作。
# Redirect from website.com to www.website.com
RewriteCond %{HTTP_HOST} ^website.com [NC]
RewriteCond %{HTTP_HOST} !^www [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# redirect url to www
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /defaultfolder/([^\ ]+)\ HTTP/
RewriteRule ^(.*)$ defaultfolder/error.php [L]
#this section hides the defaultfolder, tried to modify this code here to make friendly urls.
RewriteCond %{HTTP_HOST} www.website.com
RewriteCond %{REQUEST_URI} !defaultfolder/
RewriteCond %{REQUEST_URI} !images/
RewriteRule ^(.*)\/$ defaultfolder/$1\.php [L]
#https redirect
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} (/defaultfolder/)(login|securepages|pages)\.php
RewriteRule ^defaultfolder/(.*)$ https://www.website.com/$1 [R,L]
#http redirect
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} (/defaultfolder/)(index|nonsecure pages)\.php
RewriteRule ^defaultfolder/(.*)$ http://www.website.com/$1 [R,L]
(用更翔實的問題的標題,你可能會雖然找到更確切的重複) – mario