Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

modrewrite php question

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

New User

10+ Year Member

joined:Sept 27, 2002
votes: 0

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)

Senior Member

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

joined:Mar 31, 2002
votes: 0

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...



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members