Mobile app version of vmapp.org
Login or Join
Goswami781

: URL not found after rewrite Using this .htaccess file: Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteRule matches/(.*)-v-(.*) matches/matchevent.php?event=%20v%20 [R=301,L] This

@Goswami781

Posted in: #Htaccess #ModRewrite

Using this .htaccess file:

Options +FollowSymLinks
Options +Indexes
RewriteEngine On

RewriteRule matches/(.*)-v-(.*) matches/matchevent.php?event=%20v%20 [R=301,L]


This url: www.example.com/sport/league/matches/team1-v-team2
rewrites to: www.example.com/sport/league/matches/matchevent.php?event=team1%20v%20team2

However, the browser returns this:

Not Found
The requested URL example.com/sport/league/matches/team1-v-team2 was not found on this server.


The .htaccess file is inside the matches directory where matchevent.php is. I have also tried it in the league directory.

Could someone help me?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Goswami781

1 Comments

Sorted by latest first Latest Oldest Best

 

@Eichhorn148

I replicated your setup. There are two problems:


I can't get the %20 in the rewrite URL to work. I can get the rule to work if I replace %20 with +. A plus sign should URL decode to a space the same way a %20 does, so it should be treated the same in your matchevent.php script.
It was redirecting me to a bad relative path. If I change the redirect path to start from the root with /sport/league/matches/, it works fine.


Here is the rewrite rule that works for me:

RewriteRule matches/(.*)-v-(.*) /sport/league/matches/matchevent.php?event=+v+ [R=301,L]


I think you will want to remove the R=301 from the rewrite rule so that it doesn't do a redirect, but rather shows you the content at the pretty url:

RewriteRule matches/(.*)-v-(.*) /sport/league/matches/matchevent.php?event=+v+ [L]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme