2012-11-11 36 views
0

這非常緊迫。我需要一些htaccess規則的幫助。線索是,當用戶收到一個答案時,真正的網址將是www.mydomain.com/results.html/sth,但他必須只能在他的瀏覽器中看到www.mydomain.com/sth,而當我將他重定向到家時頁面(www.mydomain.com/index.html),網址只能是www.mydomain.com。HTACCESS - 應用一些簡單的mod_rewrite規則

感謝

+0

難道你在下面嘗試我的建議? – Sameh

回答

0
#this is for the www.yourdomain.com/index.html 
RewriteRule ^$ index.html [L] 
RewriteRule ^/$ index.html [L] 

#this is for the results 
RewriteRule ^([^/]+)$ results.html?$1 
RewriteRule ^([^/]+)/$ results.html?$1 
+0

謝謝。這適用於results.html,但不幸的是不適用於主頁index.html。鏈接到www.mydomain.com/index.html或www.mydomain.com/會帶我到www.mydomain.com/index.html或www.mydomain.com/,但會顯示www.mydomain.com/results.html的內容。 –

0

替換第3行代碼:

DirectoryIndex index.html 

應該是默認工作過,雖然

+0

仍然沒有像我之前描述的一樣。鏈接到www.mydomain.com/帶我到那裏,但不幸的是內容來自www.mydomain.com/results.html。 –

0

這應該工作:

RewriteEngine On 
RewriteCond %{REQUEST_URI} !^/(results|index)\.html 
RewriteCond %{REQUEST_URI} !^/?$ 
RewriteRule ^(.*)$ /results.html/$1 

RewriteRule ^index\.html$/[R=301,L]