Forum Moderators: phranque

Message Too Old, No Replies

search.php?Keywords=help site to help-site.html

search.php?Keywords=help site to help-site.html

         

aff_dan

8:56 am on Apr 17, 2005 (gmt 0)

10+ Year Member



Can you please help with making the following this rewrite rule for:

site.com/search.php?Keywords=help site

I want to rewrite it to something like

site.com/help-site.html

Could that code be SEO?Could be indexed by google?

Any help please?

Regards,
Dani

jd01

9:38 am on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, a URL that appears to be static is search engine friendly.

Start with the first four or five basic question posts on this page and page two of this forum to get an idea of what you need and how it's done, then you can ask specific questions after you understand how it works...

Be happy to help you out when you know what you need.

mod_rewrite only works for exact conditions, so until you know what it is and a little about how it works, there isn't too much anybody can do.

(What you are asking for looks fairly basic, but your rules have to take into account the path to where your files are located, the links you use as static links, how many variables you are passing to your php, the structure of those variables, and so on... Get an idea of how to answer these questions and you will find all the help you need.)

Justin

PS The most common mistake made when trying to use mod_rewrite is people go the wrong way. Start here and when you're done with that one, follow the link in there from jdMorgan.

[webmasterworld.com...]

aff_dan

9:52 am on Apr 17, 2005 (gmt 0)

10+ Year Member



Hi Sir,

Thank you very mcuh for your reply!

I want to make a rewrite rule site.com/search.php?Keywords=any-search-querie, it's a search querie to retrive search results from a search engine.

I want to rewrite it to more sample site.com/any-search-querie.html

Regards,
Dan

jd01

9:00 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK where to start...

1. All the links on your site that you want to use a rewrite rule for have to go to a static link,
like this: yoursite/variable/stuff.html

not like this: yoursite/yourpage.php?variable=stuff
(Yes, you need to link to a page that does not exist.)

2. All of your variables (to make the php file work) have to be included somewhere in the new 'fake' URL, and to avoid excessive rules, they should all be the same order/part of the rule or close to it.

like this:
yoursite/variable/stuff.html
yoursite/other-variable/more-stuff.html or
yoursite/variable2/stuff2.html

not like this:
yoursite/other/variable/more/stuff.html

3. When you know how this is going to be done then you can start working on your rules. The problem is they have to be exact.

so for this:
yoursite/variable/stuff.html

you could use this:
RewriteRule ^([a-z]+)/([a-z]+)\.html$ /yourpathto/yourphpfile.php?$1=$2 [L]

But of course that depends on a number of questions:
1. Do you need to pass only variable=stuff, or variable=stuff&variable2=stuff2, or more?

2. Are any of your variables numbers, this rule won't work for that.

3.How many php files do you use... do all your pages run off of one or are ther more?

4. What is the full path to your .php file(s)?

5. Are all of your pages in the same directory or are they in multiple directories?

You can't effectively rewrite, until you know have answers to these questions, and understand how the rules work...

When you get to where you understand how it works:
Post what you think will work,
A generic version of a specific url you actually have
A generic version of the specific path to your actual php file

Then I'll help you get started... I would write them for you, but that's a lot closer to work than help ;)

Justin