我有以下重写规则
<filesMatch "^(member)$">
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/(.*)/(.*)/(.*)$ /member-profile.php?ID=$2 [L]
</filesMatch>
<filesMatch "^(community-events)$">
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/(.*)/(.*)/(.*)/(.*)$ /community-events.php?ID=$3 [L]
</filesMatch>
这显然是重写了这个
mydomain.com/comunity-events/category/id/name
到这个
mydomain.com/comunity-events.php?myvariables
现在,我想要一个新的重定向,它没有一个起始的“文件夹”,比如这个
mydomain.com/business-category/business-name
到
mydomain.com/business-profile.php?variables
在给定当前配置的情况下,这是否可行,而不为每个类别名称进行重定向?
答案 0 :(得分:1)
您甚至不需要RewriteRule
指令,因为您可以匹配Options +FollowSymlinks -MultiViews
RewriteEngine On
# handle /member/...
RewriteRule ^/?(member)/(.*)/(.*)$ /member-profile.php?ID=$2 [L,QSA,NC]
# handle /community-events/...
RewriteRule ^/?(community-events)/(.*)/(.*)/(.*)$ /community-events.php?ID=$3 [L,QSA,NC]
# handle /business-category/business-name
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?(.*)/(.*)$ business-profile.php?name=$2 [L,QSA]
本身的起始部分。
您可以使用以下规则替换.htaccess:
soup.select("table#cws-search-results")