Page 1 of 1

URL Rewriting Questions..... Please Help !!!

Posted: Mon Apr 02, 2007 7:34 am
by dnmmx
Hi all PHP Geeks,

I want to enable URL-Rewriting in My Application
Actually I m a newbie for PHP.

I want to setup URL-Rewriting in a way that

If I write
http://www.site.com/page
then it should become
http://www.site.com/page/

i.e. it should add the slash at the end automatically.
and this should be happen for Every page.

and this should redirected to http://www.site.com/page.php

Please not that I m not having Domain at root, so the

RewriteBase would not be /

I m having Access to the 2nd Directory in Hierarchy. i.e. /MyDir
My Whole site is Contained within that Dir. Itself.
so the RewriteBase would be /MyDir .............Right ??

One More thing if I am Having .htaccess file at the root level and not in my directory /MyDir
does it make any diff. in writing the RewriteRule ??

As u can see I don't have any querystrings in URL, but I just want to make the URLs CLEAN
and easily Memorable.

Second, I have directory structure in my site so my URL can be like,

http://www.site.com/directory/folder/page/
this should be redirected to the page
http://www.site.com/directory/folder/page.php

I hope I make myself clear

I have tried alot but I don't have enough knowledge of RegEx, So can't do that properly.
Hope I'll find the Answer from Here.
Please Help me in writing appropriate Snippets in .htaccess file

Thanks in Advance

Posted: Tue Apr 03, 2007 12:35 am
by Benjamin
Why would it even need an ending forward slash? Have you researched what your directory structure will end up looking if you format it that way?