Htaccess按参数名称重定向

时间:2014-05-08 16:32:23

标签: .htaccess

我想知道是否有可能在具有相同参数但参数名称不同的两个网址之间存在差异。

这就是我所拥有的。但是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 个答案:

答案 0 :(得分: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]