Tutorial :Problem with mod_rewrite



Question:

I have a problem with getting my .htaccess to work like I want and I was wondering if anyone could shed a light on this.

Here is my current setup:

My shared hosting site can be accessed by http://www20.a2hosting.com/~myname/

I have several sub directories inside that I wish to access. For instance http://www20.a2hosting.com/~myname/subdir/public/index.php works just fine.

Now I'm trying to get all the calls to my subdir/public be re-directed to my index.php and to that extent I've created a .htaccess file in my subdir/public that looks as following:

RewriteEngine on   RewriteRule ^.*$ index.php  

However, when I direct my browser to http://www20.a2hosting.com/~myname/subdir/public/ I get the following 404 Error:

The requested URL /home/myname/public_html/subdir/public/index.php was not found on this server.  

What am I doing wrong?

Thanks a lot!


Solution:1

Try specifying an absolute path as the rewrite target:

  RewriteRule ^.*$ /index.php  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »