简体   繁体   English

Mod重写规则-SEO友好

[英]mod rewrite rules - SEO friendly

i made a script .. and i want to make it's all urls to be seo friendly .. 我做了一个脚本..,我想让所有的URL都是seo友好的..

my current php urls is : 我当前的php网址是:

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 : 我想问一下该页面是否具有GET Action形式,如何接受查询字符串并将其自动添加到url中..例如:

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

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. 使用mod_rewrite来实现SEO URL的目的是使您实际将网站上的所有链接更改为“漂亮”格式,然后制定一条简单的规则,将该漂亮规则转换回query_string版本。 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. 但是,这显然要求将option始终包含在option_m之前,如果这两个选项都是真正可选的,则意味着您可以在不包含option的情况下包括option_m,那么仅凭mod_rewrite就无法解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM