[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Rewriting URL (http://www.mysite.com/home/   looks at home.php)

Posted on 2008-01-30
4
Medium Priority
?
463 Views
Last Modified: 2010-03-04
I am using Apache 2.2 on Windows.  I have an URL like this:

http://www.mysite.com/home/

Which I really want to go to home.php.

(There is also http://www.mysite.com/test/ which goes to test.php etc)

I think mod_rewrite may be the solution, however, I have no experience with this.
0
Comment
Question by:944media
  • 2
4 Comments
 
LVL 24

Expert Comment

by:slyong
ID: 20784817
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ /$1.php [L]
0
 
LVL 43

Accepted Solution

by:
ravenpl earned 2000 total points
ID: 20785114
The above would work, if You will never have subdirectories. It also may produce infinite loop rewriting self to .php, then again and again

Options +FollowSymLinks
RewriteEngine on
#if the requested file with .php added exists
RewriteCond %{REQUEST_FILENAME} ^(.+?)/?$
RewriteCond %1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
0
 

Author Comment

by:944media
ID: 20788245
The recent works well with /home/.

To add a trick to it, there are additional sub directories (i.e. /home/filestructure/) which I still want to go to /home.php.

There is also /contacts/search/  which needs to go to contacts.php and soo on.
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20790668
RewriteCond %{REQUEST_URI} !\.php$
RewriteCond %{REQUEST_URI} ^/([^/]+)
RewriteRule . %1.php [L]
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses
Course of the Month10 days, 5 hours left to enroll

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question