tags:

views:

34

answers:

1

Let's say i have a main folder in my website named "test" which contains an index.php file www.myWebsite.com/test/index.php

How can i make it so that any url which contains this path "www.myWebsite.com/test" redirects to "www.myWebsite.com/test/index.php" and still hold the first request path

for example:

www.myWebsite.com/test/User       redirects to www.myWebsite.com/test/index.php
www.myWebsite.com/test/User/2     redirects to www.myWebsite.com/test/index.php
www.myWebsite.com/test/Account    redirects to www.myWebsite.com/test/index.php
www.myWebsite.com/test/Account/5  redirects to www.myWebsite.com/test/index.php
+3  A: 

Use Apache's Rewrite module. For example, in a virtual-hosts config, or in a directory's .htaccess file, you might write this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

This would make any URL that approached that directory redirect to index.php but it would not change the URL the script parses.


Here are some Godaddy.com docs on using rewrites in their hosting environment:

Bill Karwin
Dang it Bill, leave some for the rest of us. ;) +1
CaseySoftware
Thanks, I am using godaddy, any idea where i can find "httpd.config" ?
aryaxt