我正在尝试转换此网址
http://127.0.0.1/kurumsal/index.php?sayfa=referans&page=2
到这个
http://127.0.0.1/kurumsal/index/sayfa/referans/page/2/
但并非每个页面都具有引用page = 2查询字符串的分页。如果'page'查询字符串不存在,我想只使用查询字符串的第一部分。
所以没有分页查询字符串就是http://127.0.0.1/kurumsal/index/sayfa/referans/。
遵循一些教程,但没有运气,这是我的htaccess
RewriteEngine On
RewriteCond %{QUERY_STRING} !(^|&)page=($|&)
RewriteRule ^sayfa/([^/]*)/([^/]*)/$ /kurumsal/index.php?sayfa=$1&page=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^sayfa/([^/]*)/$ /kurumsal/index.php?sayfa=$1 [L]
答案 0 :(得分:1)
尝试使用此规则:
RewriteEngine On
RewriteRule ^kurumsal/index/sayfa/([^/]*)/page/([^/]*)$ /kurumsal/index.php?sayfa=$1&page=$2 [L]
答案 1 :(得分:1)
您可以在root/.htaccess
:
RewriteEngine on
RewriteCond %{THE_REQUEST} /kurumsal/index\.php\?sayfa=([^\&]+)(?:&page=)?(.*?)\sHTTP [NC]
RewriteRule ^ /kurumsal/index/sayfa/%1/%2? [L,R]
RewriteRule ^(?:kurumsal/)?index/sayfa/([^/]+)/?(.*?)/?$ /kurumsal/index.php?sayfa=$1&page=$2 [L]
答案 2 :(得分:1)
试试这个
{{1}}