我有一个像http://exmple.com/company/?n=Brunswick%20&%20Sons的网址。更改网址为htaccess中的查询var WordPress的
但我不能理解重写规则容易。我想要的查询如http://exmple.com/company/Brunswick%20&%20Sons。
任何人都可以帮助理解这个事情做这项工作100%。
我有一个像http://exmple.com/company/?n=Brunswick%20&%20Sons的网址。更改网址为htaccess中的查询var WordPress的
但我不能理解重写规则容易。我想要的查询如http://exmple.com/company/Brunswick%20&%20Sons。
任何人都可以帮助理解这个事情做这项工作100%。
尝试在根/ .htaccess中的以下代码:
RewriteEngine On
#1)Redirect from http://example.com/company/?q=foo
#to http://example.com/foo
RewriteCond %{THE_REQUEST} /company/\?n=(.+)\s [NC]
RewriteRule^/%1? [B,NC,L,R]
#first round of rewriting ends here
#2) in this round , mod_rewrite will
#internally map http://example.com/foo to
#http://example.com/company/?n=foo.
#the following 2 conditions check if the /foo is an existent directory or file, skip the rewrite
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /company/?n=$1 [B,NC,L]
你有什么已经尝试过? – hjpotter92