Forum Moderators: phranque

Message Too Old, No Replies

Rewrite database url

         

bikermanirl

9:31 am on Sep 17, 2014 (gmt 0)

10+ Year Member



hi

I need to rewite .htaccess so that www.domain.com?category is rewritten to www.domain.com/category.html

any ideas?

Thanks

phranque

9:39 am on Sep 17, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



what have you tried so far?

lucy24

7:49 pm on Sep 17, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I need to rew[r]ite .htaccess so that www.domain.com?category is rewritten to www.domain.com/category.html

:: peering into crystal ball ::

No, you don't. You need to redirect so that requests for
www.example.com?category
are redirected to
www.example.com/category.html
or possibly just
www.example.com/category
(Extensionless URLs give me the fantods, but they seem to be in fashion :()

and then you need to rewrite requests for
www.example.com/category.html
or possibly
www.example.com/category
to serve content from
www.example.com?category=something-or-other
(or possibly ?something-or-other=category. Yes, I realize ?category alone is technically possible, but it seems unlikely.)

bikermanirl

1:17 pm on Sep 25, 2014 (gmt 0)

10+ Year Member



Its a site created in the 90's with a .html extension being rewriten to be data driven and I dont fancy losing rankings for a few thousand pages by losing the .html.

There is a list of categories each with a page of links to appropiate sections, the database selects the category and lists the content.

For example www.domain.com?programmers will produce a list of things in programmer category of the database.

We have had the mysql query hard coded into the existing html pages for years and serving them as php, now im looking for a solution which will dynamically create the pages.

I've seen thousands of sites do this but .htaccess files are not my strong point.

lucy24

8:36 pm on Sep 25, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Same answer, still. Just use the "category.html" version rather than the "category" version.

Forms like
www.example.com?programmers
make no sense as rewrite targets, because then mod_dir has to go look up what the actual name of the directory file is. Since you're not dealing with a visible URL, rewrite to the real, physical file that will be processing the data, and put the query string in the most unambiguous form.

If nobody has ever used or even seen the URL
www.example.com?category
you can probably ignore the redirect half of the process. But check your logs periodically to make sure nobody gets wise.

[edited by: phranque at 8:52 am (utc) on Sep 26, 2014]
[edit reason] typo correction requested [/edit]