Url rewrite

Hi,

I want to support to rewrite url for website.

I want to change url

FROM http://mydomainname.com/How-It-Works.php TO http://mydomainname.com/How-It-Works/
FROM http://mydomainname.com/FAQs.php TO http://mydomainname.com/FAQs/
FROM http://mydomainname.com/About-Us.php TO http://mydomainname.com/About-Us/
FROM http://mydomainname.com/Contact-Us.php TO http://mydomainname.com/Contact-Us/

Any idea?

-Thanks

Off Topic:

A bit off topic here, but you can do that without URL rewriting by renaming a file like About-Us.php to index.php and then placing it in a directory called /About-Us/. You may not want to go to that trouble now, but that’s my preferred method.

edge,

Aw, I’ve addressed the “loopy redirection” which you’re asking for years ago in my signature’s tutorial.

Another (warning) comment, though, is that you should never (IMHO, of course) specify a directory name when you’re looking to match a file name, i.e., drop the trailing slashes UNLESS they are directory requests (primarily because internal requests would be offset from internal requests).

Regards,

DK

Many thanks guys for support.

Following my solution.

RewriteEngine on 

RewriteRule ^/?FAQs.html$ FAQs.php [L]

RewriteRule ^/?How-It-Works.html$ How-It-Works.php [L]

-Thanks

edge,

I’m glad to see that you’re not using directories in place of file names as shown in post#1. I hope you understand the problems with doing that.

As far as your solution goes:

  1. If you’re using Apache 2.x, you no longer need to worry about the leading slash (it will NOT match in the DocumentRoot) so you can delete the /? in each RewriteRule.

  2. Showing .html file extensions? That makes it easy except you really should escape the dot character before html in each RewriteRule.

  3. If you decide to show extensionless file names, simply delete the .html from each RewriteRule and it should work perfectly.

You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too.

Regards,

DK