如何使用htaccess重写这个长网址以缩短它

时间:2013-11-22 20:11:10

标签: .htaccess mod-rewrite

我的网站菜单上有一个链接 http://www.website.com/index.php?mid=store_name&sort_index=store&order_type=asc

我想把它变成http://www.website.com/store_name

我几乎花了一整天时间努力完成这项工作,并在整个网络上查看并尝试了不同的例子,但无法让它发挥作用。

我不知道为什么这不起作用

RewriteRule ^store_name/?$ index.php?mid=store_name&sort_index=store&order_type=asc [NC,L]

任何想法?我很感激任何意见,谢谢。

------这是整个htaccess --------

RewriteEngine On

# reserve XE Layout Template Source File (*.html)
RewriteRule ^(layouts|m.layouts)/(.+)\.html$ - [L,F]
# reserve XE Template Source Files (*.html)
RewriteCond %{REQUEST_URI} !/modules/editor/
RewriteRule /(skins|m.skins)/(.+)\.html$ - [L,F]

# store_name rewrite
RewriteRule ^store_name/?$ index.php?mid=store_name&sort_index=store&order_type=asc [NC,L]

# conf, query, schema
RewriteRule ^(modules|addons|widgets)/(.+)/(conf|queries|schemas)/(.+)\.xml$ ./index.php [L]

# static files
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.+)/files/(member_extra_info|attach|cache|faceOff)/(.*) ./files/$2/$3 [L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.+)/(files|modules|widgets|widgetstyles|layouts|m.layouts|addons)/(.*) ./$2/$3 [L]

# rss , blogAPI
RewriteRule ^(rss|atom)$ ./index.php?module=rss&act=$1 [L]
RewriteRule ^([a-zA-Z0-9_]+)/(rss|atom|api)$ ./index.php?mid=$1&act=$2 [L]
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/(rss|atom|api)$ ./index.php?vid=$1&mid=$2&act=$3 [L]

# trackback
RewriteRule ^([0-9]+)/(.+)/trackback$ ./index.php?document_srl=$1&key=$2&act=trackback [L]
RewriteRule ^([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ ./index.php?mid=$1&document_srl=$2&key=$3&act=trackback [L]
RewriteRule ^([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ ./index.php?vid=$1&document_srl=$2&key=$3&act=trackback [L]
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ ./index.php?vid=$1&mid=$2&document_srl=$3&key=$4&act=trackback [L]

# document permanent link
RewriteRule ^([0-9]+)$ ./index.php?document_srl=$1 [L,QSA]

# mid link
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_]+)/?$ ./index.php?mid=$1 [L,QSA]
# mid + document link
RewriteRule ^([a-zA-Z0-9_]+)/([0-9]+)$ ./index.php?mid=$1&document_srl=$2 [L,QSA]

# vid + mid link
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/?$ ./index.php?vid=$1&mid=$2 [L,QSA]
# vid + mid + document link
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([0-9]+)$ ./index.php?vid=$1&mid=$2&document_srl=$3 [L,QSA]

# mid + entry title
RewriteRule ^([a-zA-Z0-9_]+)/entry/(.+)$ ./index.php?mid=$1&entry=$2 [L,QSA]
# vid + mid + entry title
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/entry/(.+)$ ./index.php?vid=$1&mid=$2&entry=$3 [L,QSA]

#shop / vid / [category|product] / identifier
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([a-zA-Z0-9_\.-]+)$ ./index.php?act=route&vid=$1&type=$2&identifier=$3 [L,QSA]

1 个答案:

答案 0 :(得分:0)

RewriteRule ^ store_name /(.+)index.php?mid = store_name& sort_index = store& order_type = asc [NC,QSA,L]

今天早上,Kalle对我这么强硬。我认为它可能对你有用,因为它对我有用。 :)