On Fri, May 17, 2013 at 5:53 AM, Byron Clark <[email protected]> wrote:
>
> One way to do this is to use mod_rewrite[1] with Apache to translate URLs
> from /index.php/PAGE_NAME to /index.php?section=PAGE_NAME. Since you
> pointed to a MediaWiki site as your example, you may be interested in the
> MediaWiki manual section that describes how to setup the redirects[2].
>
> [1] http://httpd.apache.org/docs/current/mod/mod_rewrite.html
> [2] http://www.mediawiki.org/wiki/Manual:Short_URL/Apache
>
> --
> Byron Clark


You might use the following code in your .htaccess file

RewriteEngine on
RewriteBase /
RewriteRule ^([A-Za-z]+)/([A-Za-z]+)$ index.php?query=$1

This would actually take the index.php out of your URL string and make
the following URL:
http://domain/PAGE_NAME
redirect invisibly to
http://domain/index.php?query=PAGE_NAME

If you want to do multiple queries from the URL, you could do:
RewriteRule ^([A-Za-z]+)/([A-Za-z]+)$ index.php?page=$1&subpage=$2

And that would take the URL:
http://domain/PAGE_NAME/SUB_PAGE
and redirect invisibly to
http://domain/index.php?page=PAGE_NAME&subpage=SUB_PAGE

+ Hat tip to Paul Ellsworth for teaching me that a few years ago.

And, I'd like to renew my PLUG list membership now for three years
seeing I may have actually contributed to something meaningful (rather
than scraping the list for engineers to harass with alternate jobs,
per the norm). And I trimmed/bottom-posted. Let the Old Ways always be
respected.

--
Robert Merrill
801-228-0529 (calls/txts OK)

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to