我已将example.com/service.php?p_id=1&s_id=seo中的网址重写为example.com/1/seo/。 通过以下规则:
此规则适用于example.com/services.php?p_id=1&s_id=seo
RewriteEngine On
RewriteCond %{THE_REQUEST} /services\.php\?p_id=([^&\s]+)&s_id=([^&\s]+) [NC]
RewriteRule ^ /%1/%2/? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ services.php?p_id=$1&s_id=$2 [QSA,L]
现在的问题是,当我将另外的网址使用以下规则时,例如example.com/about-us.php?p_id=1&s_id=2和example.com/it-training.php?p_id=1& ; s_id = 2然后url重定向为example.com/1/2/index.php但它应该是example.com/1/2,
关于-us.php的格式化规则如下所示
RewriteEngine On
RewriteCond %{THE_REQUEST} /about-us\.php\?p_id=([^&\s]+)&s_id=([^&\s]+) [NC]
RewriteRule ^ /%1/%2/? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ about-us.php?p_id=$1&s_id=$2 [QSA,L]
在其他情况下,我有一些像example.com/packages.php,index.php的网址,我也想从那种文件中删除.php