Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

modrewrite php question



1:59 am on Nov 2, 2002 (gmt 0)

10+ Year Member

Is it possible to make domain.com/content.php?id=name
into domain.com/content/name.html BUT have hits on domain.com/content just load the index page for that directory?


2:26 am on Nov 2, 2002 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

RewriteCond %{QUERY_STRING} ^id\=(.+)$
RewriteRule ^content\.php /content/%1.html [L]
RewriteRule ^content\.php /content/index.html [L]

-- or just use --

RewriteRule ^content\.php /content/ [L]

for the second rule if /content/ will resolve to your index file as-is

If the query string is contains id=(something)
Then rewrite /content.php?id=something to /content/(something).html and QUIT rewriting because of [L]
Otherwise fall through to the next rule, which unconditionally
rewrites /content.php to /content/index.html or /content/ if you use the second version

If you do this is .htaccess, this should work as-is. Otherwise you should use ^/content everywhere you see ^content now.

Hope it's clear...



Featured Threads

Hot Threads This Week

Hot Threads This Month