2012-11-11 31 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]