views:

39

answers:

1

hello , i made a script .. and i want to make it's all urls to be seo friendly ..

my current php urls is :

index.php?lang=ar&option=a&option_m=band variable option&option_m are optional

so i want convert this url to

/ar/a/b

or

/ar/a

or

/ar

and i want ask about if the page have form with GET Action ,, how to accept the query string and add it in the url automaticly .. such as :

/ar/a/b/input1-value/input2-value

thanx

A: 

The objective of using mod_rewrite to achieve SEO URLs is for you to actually change all links on your site to the 'pretty' format, then to make a simple rule that can convert this pretty rule back into the query_string version. In your case you would be using something similar to this...

RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9-]+)/?$ index.php?lang=$1
RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ index.php?lang=$1&option=$2
RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ index.php?lang=$1&option=$2&option_m=$3

This obviously however requires that option will always be included before option_m, if both are truly optional, meaning you can include option_m without option, then there is really no way round it with mod_rewrite alone.

Cags
hello ..thx alot .. ok it's helped me .. but what about query string and forms action ?? what is hte method to make it's urls pretty with seo ?
Jason4Ever
I don't understand the question. A form action is the same as any other link. If you mean if the form is set to GET, then the simple answer is that you can't do it. You could perhaps create a hack that would 301/302 the query string version to a pretty version that would then substitute a query string version, but will be hacky.
Cags