mod-rewrite forwarding without changing URL

给你一囗甜甜゛ 提交于 2019-12-11 02:37:27

问题


I have a small problem with my Apache configuration when creating "pretty" URLs. I've got it to the stage where typing (or linkig for that matter) to

index.html

forwards you to

index.php?pageID=Forside

that is exactly what I want. But how can I get index.html to stay in the address bar of the browser? Right now it forwards and changes the URL to the original one.

Here my .htaccess:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} index\.html
RewriteRule .* http://www.radoor-designs.dk/index.php?pageID=Forside [L]

And before someone comments on it: Options +FollowSymLinks is missing since it triggers an error 500 on a one.com webhotel.

Thanks in advance!


回答1:


Try the following:

RewriteEngine On
RewriteRule ^index\.html$ /index.php?pageID=Forside [L]

I think this may help you to resolve your problem.




回答2:


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index.html$  /index.php?pageID=Forside [L]

This will do the redirect for you whilst showing index.html in the browser window.




回答3:


Strange that symbolic links creates an error 500, if you want it to redirect to index.html?pageID=Forside then do

RewriteRule .* /index.html?pageID=Forside [QSA,L,R=301]

I'm not 100% certain what you are trying to achieve with this could you explain a little more?



来源:https://stackoverflow.com/questions/14171293/mod-rewrite-forwarding-without-changing-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!