Htaccess problem

Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
SpaceshipSpaceship
Watch

Barrucadu

Established Member
Impact
64
Here is the relavent bit of the file:
Code:
# Redirect old backlinks
RewriteRule ^(game|video).php?(game|video)=(.*)$ $1/$3/ [R=301]

BUT, it dosn't work, example. However, other redirects work fine.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Could it be that the ? needs to be escaped, so it would become:
Code:
# Redirect old backlinks
RewriteRule ^(game|video).php\?(game|video)=(.*)$ $1/$3/ [R=301]
as according to http://www.ilovejackdaniels.com/regular_expressions_cheat_sheet.pdf it is a character that needs escaping, since in that rule it looks as if you want it to be part of the address that is rewrited

Lee
 
0
•••
Nope, that didn't do it.

Although, I found that (game|video).php?(.*) matches the url, so it seems to be the (game|video)= that seems to be breaking it. I've tried \=, but that didn't work either.
 
Last edited:
0
•••
I am really confused, I just tried the following:
Code:
RewriteRule ^game.php?game=(.*)$ game/$1/ [L,R=301]
RewriteRule ^video.php?video=(.*)$ video/$1/ [L,R=301]

And it STILL dosn't work... Could something else in my htaccess file be interfering with it? Here is the whole file:
Code:
# Settings
RewriteEngine on 
RewriteBase /

# Prepend the www. if not present
RewriteCond %{HTTP_HOST} !^www.yarrt.com$ [NC]
RewriteRule ^(.*)$ http://www.yarrt.com/$1 [L,R=301]

# Redirect old backlinks
RewriteRule ^game.php?game=(.*)$ game/$1/ [L,R=301]
RewriteRule ^video.php?video=(.*)$ video/$1/ [L,R=301]
RewriteRule ^(games|videos).php?p=([0-9]+)&order=(file|views)$ $1/start-$2/sort-$3/ [L,R=301]
RewriteRule ^(games|videos).php$ $1/start-0/sort-file/ [L,R=301]

# URLs in the format of: (games|videos)/[p]/[order](/|)
RewriteRule ^(games|videos)/start-([0-9]+)/sort-(file|views)(/|)$ list.php?type=$1&p=$2&order=$3 [L]

# URLs in the format of: (game|video)/[name](/|)
RewriteRule ^(game|video)/(.*)/$ play.php?mode=$1&item=$2 [L]
RewriteRule ^(game|video)/(.*)$ play.php?mode=$1&item=$2 [L]

# URLs in the format of: fullscreen/(game|video)/[name](/|)
RewriteRule ^fullscreen/(game|video)/(.*)/$ fullscreen.php?type=$1&item=$2 [L]
RewriteRule ^fullscreen/(game|video)/(.*)$ fullscreen.php?type=$1&item=$2 [L]

# Redirect errors
ErrorDocument 404 /error.php?e=404
ErrorDocument 500 /error.php?e=500
 
Last edited:
0
•••
I know this may be a stupid thing to say, but isn't the rule the wrong way round? From the rule you have put, isn't it redirecting game.php?game=gamename to /game/gamename so to a folder which doesn't exist?
 
0
•••
It is redirecting to the url I want which is then rewritten to the actual file - its a bit of a roundabout way, but it achieves what I want. The other 2 rules in that section work fine, so my (possibly flawed) logic isn't the problem
 
0
•••
I haven't got time at the moment to look into this, so try this.

Code:
 RewriteRule ^/(game|video)/(.+)$ /$1.php\?$1=$2 [QSA,L]
 
Last edited:
0
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back