Apache2 CentOS 6

I am trying to work out how to make an Apache VHost send all of its requests to an index page as a kind of bootstrap. I do not wish to alter the look of URL, however all requests should call the same index.php file..

http://url.com/one
http://url.com/
http://url.com/one/two/three

The above examples should all land on the index page..

Thanks for any help.. My brain is hurting from this..

EDIT: I seem to get somewhere until i surf to an existing directory.. At this point, the rewrite rules dont seem to work..

Thanks,

<VirtualHost *:80>
   ServerName project_boot
   DocumentRoot /var/www/html/project_boot

   <Directory "/var/www/html/project_boot">
      AllowOverride None
      RewriteEngine On
      RewriteRule ^/.*$ /index.php [QSA,L]
   </Directory>
</VirtualHost>
link|improve this question

80% accept rate
ServerName project_boot does this actually exist ? i.e. is there a way for a client to land on this vhost and use this hostname ? Prove (with logs) that anything actually lands on this vhost. – adaptr Oct 18 '11 at 14:53
feedback

2 Answers

up vote 1 down vote accepted

Please, please direct people to the current documentation!

The above "solution" specifically causes a [R]edirect - which is not what the OP wants.

Outside your vhost:

LoadModule rewrite_module modules/mod_rewrite.so

Inside your vhost:

AllowOverride None
RewriteEngine On
RewriteRule ^/.*$ /index.php [QSA,L]

The allowoverride disables any .htaccess files that may exist, and the QSA appends any existing query string to the new URL (if that is what you want).

link|improve this answer
Thanks for the reply.. I have added your changes to my VHOST conf, but it appears to not be applying.. I will paste into the OP. Thanks again.. – Lee Oct 18 '11 at 14:50
Ok thank you, i see where i was going wrong.. Almost there now.. I just need to ignore css/js and image files.. – Lee Oct 18 '11 at 15:01
You could pass the rest of the URL as an argument: RewriteRule ^/(.*) /index.php?rest=/$1 [QSA,L] – Olivier Pons Oct 18 '11 at 16:31
feedback

(Untested)

RewriteEngine on
RewriteRule   ^/.*  /index.ph  [R]

Read http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Cheers.

link|improve this answer
Sorry, didnt work. I tested something like that.. I always ran into the problem of the index.php page being added.. or when a directory that existed was added in the URI, it allowed it through. – Lee Oct 18 '11 at 13:48
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.