Name.com: Automate your domain portfolio. Zero API fees. Claim your token.

Htaccess problem

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
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
Close
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
Close
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
Close
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
Close
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
Close
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
Close
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
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

NamePros now runs XenForo 2.3
We upgraded the forum software to a new version, XenForo 2.3. Thank you for your patience while the forums were offline. Your posts...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back