Any .htaccess rewrite rule gods in here?

Started by Peder 🚀, Wed 02/06/2010 12:44:24

Previous topic - Next topic

Peder 🚀

For some reason agsarchives.com is not working like it should on the dedicated server.
It has the same .htaccess file as on the old server, the server is set up to allow use of .htaccess files and mod_rewrite is enabled.

www.agsarchives.com - Old
new.agsarchives.com - New

The .htaccess file looks like this:
Code: ags

RewriteEngine On
RewriteCond %{http_host} ^agsarchives.com [nc]
RewriteRule ^(.*)$ http://www.agsarchives.com/$1 [r=301,nc]
RewriteBase /

RewriteRule ^gamecard/([0-9]+)$ /gamecard/$1/
RewriteRule ^gamecard/([0-9]+)/$ /gamecard.php?game_id=11
RewriteRule ^gamecard/([0-9]+)/([^/]+)\.html$ /gamecard.php?game_id=$1
RewriteRule ^gamecard/([0-9]+)/([^/]+)$ /game-screen-files/$1/$2
RewriteRule ^gamecard/([^/]+)\$ /game-screen-files/$1

RewriteRule ^companycard/([0-9]+)$ /companycard/$1/ [R]
RewriteRule ^companycard/([0-9]+)/$ /companycard.php?company_id=$1
RewriteRule ^companycard/([0-9]+)/([^/]+)\.html$ /companycard.php?company_id=$1
RewriteRule ^companycard/([0-9]+)/([^/]+)$ /upload/logos/$1/$2
RewriteRule ^companycard/([^/]+)\.jpg$ /upload/logos/no-logo.jpg

RewriteRule ^catalogue/([^/]+)\.html$ /catalogue.php?action=$1&filter=active
RewriteRule ^catalogue/([^/]+)/([^/]+)/([^/]+)\.html$ /catalogue.php?action=$1&$2=$3&filter=active
RewriteRule ^catalogue/([^/]+)/([^/]+)/([^/]+)/([^/]+)\.html$ /catalogue.php?action=$1&$2=$3&filter=active

RewriteRule ^download/([^/]+)/([0-9]+)$ /download/$1/$2/ [R]
RewriteRule ^download/([^/]+)/([0-9]+)/$ /download.php?$1=$2
RewriteRule ^download/([^/]+)/([0-9]+)/([^/]+)\.html$ /download.php?$1=$2

RewriteRule ^download-file/([^/]+)/([0-9]+)$ /download-file/$1/$2/ [R]
RewriteRule ^download-file/([^/]+)/([0-9]+)/$ /download-file.php?$1=$2
RewriteRule ^download-file/([^/]+)/([0-9]+)/([^/]+)\.html$ /download-file.php?$1=$2

RewriteRule ^engine/archive\.html$ /engine-archive.php
RewriteRule ^news/post_id/([0-9]+)/([^/]+)\.html$ /news.php?show_post=$1

RewriteRule ^user/account\.html$ /user-account.php
RewriteRule ^user/inbox\.html$ /user-inbox.php
RewriteRule ^user/games\.html$ /user-games.php
RewriteRule ^user/tools-mods\.html$ /user-tools-mods.php
RewriteRule ^user/stats\.html$ /user-stats.php
RewriteRule ^admin/account\.html$ /admin-account.php
RewriteRule ^admin/inbox\.html$ /admin-inbox.php
RewriteRule ^admin/games\.html$ /admin-games.php
RewriteRule ^admin/tools-mods\.html$ /admin-tools-mods.php
RewriteRule ^admin/stats\.html$ /admin-stats.php

RewriteRule ^([^/]+)\.html$ /$1.php

On the dedicated server is does follow some of the rules, but specially urls like this:
http://www.agsarchives.com/gamecard/1125/the-hitchhikers-guide-to-the-galaxy-remake.html
It does not "like".
It basically will just open gamecard.php (it redirects too the main page because ive set it too do so if no game_id is given.).

Anyone know what might be causing this?

PS! also gotta note that it seems to just change everything to $.php
So if you type in http://new.agsarchives.com/$anyfile
where $anyfile is any file in the root folder, it will open that file..


Best regards,
Peder Johnsen.

Peder 🚀

Sorry for double post. reason I am is because people that has allready read this might now be able to help as Ive discovered something.

If the link used is actually a file on server it will load that file.
I tried changing the url too http://new.agsarchives.com/gamecarde/1125/the-hitchhikers-guide-to-the-galaxy-remake.html and it now works. So anybody know what might be making it act this way?
Could it be some settings outside the .htaccess file?

Wyz

Well, the thing is, the rewrite rules are done recursively. The resulting url is again called, and if rewrite rules apply to it it will we altered yet again. You could enable logging for rewrite, then you could inspect each step, and see where it goes wrong.

I'd like to have a look at it, but I must be high on caffeine for that.  ;D
Life is like an adventure without the pixel hunts.

Peder 🚀

#3
Lol, well now I know what it does wrong.. as mentioned in my last post it basically first (for some unknown reason) checks if any url written like this domain.com/something/ is a file : domain.com/something.php.

Infact I just removed the .htaccess file and it still does that. so there is definatly some server settings somewhere that it listens to.
Anyone know where such a file could be set to do anything on an unbutu server?

Peder 🚀

It was apache doing it! All fixed now :).

SMF spam blocked by CleanTalk