首页 文章

Htaccess redirec按参数名称

提问于
浏览
0

我想知道是否有可能在具有相同参数但具有不同参数名称的两个URL之间进行差异化 .

这就是我所拥有的 . 但是htaccess总是返回第一个选项:-(

有人能以正确的方式指出我吗?

这些都是网址

https://xxxxxx/videos.php?categoria=Mimo&orden=fecha

https://xxxxxx/videos.php?orden=views&limit=5

这就是我想要的方式

https://stars.pullmantur.es/pull/Mimo/Fecha

https://stars.pullmantur.es/pull/views/5
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^categoria=([A-Za-z\+]+)&orden=([A-Za-z0-9\+]+)$
RewriteRule videos\.php$ participantes-casting-online/%1/%2? [R=301,L]
RewriteRule ^participantes-casting-online/([^/]*)/([^&]+)$ videos.php?categoria=$1&orden=$2 [L,NC,QSA]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^orden=([A-Za-z\+]+)&limit=([,0-9\+]+)$
RewriteRule videos\.php$ participantes-casting-online/%1/%2? [R=301,L]
RewriteRule ^participantes-casting-online/([^/]*)/([^&]+)$ videos.php?orden=$1&limit=$2 [L,NC,QSA]

谢谢

1 回答

  • 1

    将此代码放在 DOCUMENT_ROOT/.htaccess 文件中:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} \s/+videos\.php\?orden=([&]+)&limit=([0-9]+) [NC]
    RewriteRule ^ /pull/%1/%2? [R=302,L]
    
    RewriteCond %{THE_REQUEST} \s/+videos\.php\?categoria=([^&]+)&orden=([^\s&]+) [NC]
    RewriteRule ^ /pull/%1/%2? [R=302,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^pull/([^/]+)/([0-9]+)/?$ /videos.php?orden=$1&limit=$2 [L,NC,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^pull/([^/]+)/([0-9]+)/?$ /videos.php?categoria=$1&orden=$2 [L,NC,QSA]
    

相关问题