Вопрос

Hello my problem is rewriting URL of two different pages that have same query value.
Example: /players.php?name=Messi and /clubs.php?name=Barcelona

My .htaccess is :

Options +FollowSymLinks -MultiViews
RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+club\.php\?name=([^&\s]+) [NC]
RewriteRule ^ /%1-Football-Wallpapers? [R=301,L] 
RewriteRule ^/([^/]+)-Football-Wallpapers/?$ /club.php?name=$1 [L,QSA,NC]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+player\.php\?name=([^&\s]+) [NC]
RewriteRule ^ /%1-Football-Wallpapers? [R=301,L] 
RewriteRule ^([^/]+)-Football-Wallpapers/?$ /player.php?name=$1 [L,QSA,NC]<br>

If i use only one of the rules everything is ok for club.php?name=barcelona page, but when i use both of them and i try to open player.php?name=messi i get redirect to club.php.
Is it possible to mistake in flag i use?

Это было полезно?

Решение

You have one same rule for 2 different pages. The rewrite engine does not make any difference, it takes the first one (here club.php)

A simple example is to add something in player rule:

RewriteRule ^([^/]+)-Football-Wallpapers-Player/?$ /player.php?name=$1 [L,QSA,NC]

Now you have an internal redirect from Football-Wallpapers to club.php and Football-Wallpapers-Player to player.php

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top