mod-rewrite forwarding without changing URL

2019-07-20 01: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?