Apache
Hi,
I want to achive the following goal: If a request is made for any .html file I want server to open index.html. The most important thing is the URL must stay the same so ModRewrite and redirects are out od scope. I kind of achieved it by setting index.html as an 404 error page, but the problem is that all form posted data is lost. Thank you for you help. |
Hi,
Well what you want is achieved by two this ... 404 error page and with mod_rewrite :) So mod_rewrite is not out of scope.. Let me explain you mod_rewrite here .. If you request a page say http://www.example.com/abc.html than what your Web server(apache) does with mod rewrite it will read the url, if it is in form /[a-zA-Z-].html than it will execute /index.html though the Browser never comes to know that a different page is executed. If you don't believe me try some Price comparison sites they mostly use mod_Rewrite. and in technical term its URL rewriting.. and for post data well you have to be careful and I am not sure if you can achieve it with 404 page also 404 will not keep this Quote:
|
Thanks for reply. I tried mod_rewrite and it seems that URL in browser does not change so it is what I wanted. The peoblem is that the following rule will perform an infinite number of redirects (loop):
RewriteEngine On RewriteCond %{REQUEST_URI} /.*\.html RewriteRule /* /index.html Any .html url will be redirected to index.html but index.html will also be redirected to index.html and so forth I tried to create a suitable rule to exclude index.html, with no success. Can you help? Two files should be omitted from the redirect (index.html and admin.html) |
Hi,
you rule Code:
RewriteRule /* /index.html I am not sure as i never try this, but you can do it like this ... Code:
/[^index|admin]*?\.html /index.html though this will also work with http://www.example.com/images/somepage.html to http://www.example.com/index.html What I prefer is you make your pages like this if possible http://www.example.com/pages/pagename.html this way you can check this /pages/(.*)?\.html /index.html also there are ending directives like L,Q,S,A etc... not sure what they does, but are for rule conditions Hope that help you |
All times are GMT -5. The time now is 09:27 PM. |