homepage Welcome to WebmasterWorld Guest from 54.198.33.96
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
modrewrite php question
stratocaster




msg:1516205
 1:59 am on Nov 2, 2002 (gmt 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?

 

jdMorgan




msg:1516206
 2:26 am on Nov 2, 2002 (gmt 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...

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved