Reputation: 93
applied a RewriteRule
RewriteRule ^([^/]*)/([^/]*)/basic/?$ /basic.php?player=$2&platform=$1 [NC]
for converting
/basic.php?player=$2&platform=$1
URL to pretty
/$1/$2/basic
then applied
RewriteRule ^pc/([^/]*)/?$ /pc/$1/basic/ [NC,R=301]
for redirecting this
/$1/$2
to this
/$1/$2/basic
the problem is when entering only this
/$1
it shows 404 not found error page but when entering
/$1/
it redirects to
/$1/basic/basic
Is there any way to display a 404 Not Found error page instead
here is my .htaccess
<IfModule mod_rewrite.c>
Options -Indexes
RewriteEngine on
#redirect -- /platform/player/ => /platform/player/basic
RewriteRule ^pc/([^/]*)/?$ /pc/$1/basic/ [NC,R=301]
RewriteRule ^ps3/([^/]*)/?$ /ps3/$1/basic/ [NC,R=301]
RewriteRule ^ps4/([^/]*)/?$ /ps4/$1/basic/ [NC,R=301]
RewriteRule ^xbox/([^/]*)/?$ /xbox/$1/basic/ [NC,R=301]
RewriteRule ^xone/([^/]*)/?$ /xone/$1/basic/ [NC,R=301]
#format -- /platform/player/page
RewriteRule ^([^/]*)/([^/]*)/basic/?$ /basic.php?player=$2&platform=$1 [NC]
RewriteRule ^([^/]*)/([^/]*)/weapons/?$ /weapons.php?player=$2&platform=$1 [NC]
RewriteRule ^([^/]*)/([^/]*)/vehicles/?$ /vehicles.php?player=$2&platform=$1 [NC]
RewriteRule ^([^/]*)/([^/]*)/awards/?$ /awards.php?player=$2&platform=$1 [NC]
RewriteRule ^([^/]*)/([^/]*)/kititems/?$ /kititems.php?player=$2&platform=$1 [NC]
ErrorDocument 400 /errordoc/error.php?error=400
ErrorDocument 401 /errordoc/error.php?error=401
ErrorDocument 403 /errordoc/error.php?error=403
ErrorDocument 404 /errordoc/error.php?error=404
ErrorDocument 500 /errordoc/error.php?error=500
Upvotes: 1
Views: 1398
Reputation: 143966
The /$1/
is matching the first
RewriteRule ^pc/([^/]*)/?$ /pc/$1/basic/ [NC,R=301]
rule because you have optional *
and /?
patterns, so /pc/
will match that regex. Make those fields required fields instead:
#redirect -- /platform/player/ => /platform/player/basic
RewriteRule ^pc/([^/]+)/?$ /pc/$1/basic/ [NC,R=301]
RewriteRule ^ps3/([^/]+)/?$ /ps3/$1/basic/ [NC,R=301]
RewriteRule ^ps4/([^/]+)/?$ /ps4/$1/basic/ [NC,R=301]
RewriteRule ^xbox/([^/]+)/?$ /xbox/$1/basic/ [NC,R=301]
RewriteRule ^xone/([^/]+)/?$ /xone/$1/basic/ [NC,R=301]
by changing the *
to a +
.
Upvotes: 1