Url's without extensions (i.e. www.mysite.com/mypage )

5 views
Skip to first unread message

baiwan

unread,
Sep 12, 2007, 11:13:47 AM9/12/07
to Apache .htaccess
My current site uses the following to direct a url ending .html to a
page handler at index.php

RewriteRule ^(.*).html$ /index.php

For my next site, I want to use a similar rewrite rule to have
extension-less url's, (i.e. "www.mysite.com/mypage" ).

My ability with regex is limited however. Can anyone supply a suitable
expression? I'd really appreciate it!

Thanks!

Apache Admin

unread,
Sep 17, 2007, 2:34:37 PM9/17/07
to Apache .htaccess
Well you can take a look at how wordpress does this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Which basically redirects any request for a non-existing file or
directory to be transparently redirected to /index.php so a request
for mysite.com/mypage would show /index.php but the address in the
browser would still read mysite.com/mypage

Reply all
Reply to author
Forward
0 new messages