LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-19-2006, 01:05 PM   #1
pave
Member
 
Registered: Oct 2004
Posts: 42

Rep: Reputation: 16
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.
 
Old 05-20-2006, 06:19 AM   #2
vikasumit
Member
 
Registered: Apr 2006
Location: Delhi, India
Distribution: Fedore , CentOs, Debian
Posts: 121

Rep: Reputation: 15
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:
The most important thing is the URL must stay the same
it willbe achieve by mod_Rewrite module of apache..
 
Old 05-21-2006, 07:15 AM   #3
pave
Member
 
Registered: Oct 2004
Posts: 42

Original Poster
Rep: Reputation: 16
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)
 
Old 05-21-2006, 11:58 PM   #4
vikasumit
Member
 
Registered: Apr 2006
Location: Delhi, India
Distribution: Fedore , CentOs, Debian
Posts: 121

Rep: Reputation: 15
Hi,

you rule
Code:
RewriteRule /* /index.html
define that any thing after tld is gone to index page which means even a image request will be thrown to index.html page

I am not sure as i never try this, but you can do it like this ...

Code:
/[^index|admin]*?\.html /index.html
it says if not index or admin and comes infinitely till first period (.) followed by HTML will be gone to 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
 
  


Reply

Tags
apache, redirect



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail from Apache being rejected - Cannot route to sender apache@localhost.localdomain jimwillsher Linux - Networking 2 01-19-2006 12:41 AM
Apache 1.3.33 (debian built) and Apache SSL does not respond to the proper ports lqorg_user Linux - Networking 0 11-06-2005 04:11 PM
Strange apache trailing / problem - Slack-current, apache 1.3.33 vamp Linux - Networking 1 01-30-2005 07:28 PM
Apache Webserver 403 Forbidden Errors (User not in apache group?) Mankind75 Mandriva 4 07-08-2004 05:30 AM
apache benchmarks (apache v13 / apache v20) ; large differences between benchmarking markus1982 Linux - Software 0 02-08-2003 10:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration