FreePgs.com Forum

FreePgs Related => Support Requests => Topic started by: Guide on November 13, 2005, 06:15:09 PM

Title: [htaccess] RewriteEngine
Post by: Guide on November 13, 2005, 06:15:09 PM
Hello,

I tried to use the .htaccess RewriteEngine in order to forward url's of the type /mylang_mypage.html into the real pages whose name are of the form index.php?lang=mylang&page=mypage.
I used the following .htaccess in the root directory:

QuoteRewriteEngine On

RewriteRule ^(fr|en|es|nl)_([a-zA-Z]*).html /index.php?page=$2&lang=$1
RewriteRule ^index.html$ /index.php

Yet it doesn't word. Does freepgs.com not allow the RewriteEngine, or is my .htaccess wrong? (It did work on the temporary host I took during freepgs' downtime)
Title: Re: [htaccess] RewriteEngine
Post by: webzone (archived) on November 13, 2005, 06:17:41 PM
I am not an expert of mod_rewrite, however I can tell you that the cause of the problem is in your .htaccess because mod_rewrite works perfectly well on freepgs.com and the temporary plesk server.
Title: Re: [htaccess] RewriteEngine
Post by: Guide on November 13, 2005, 06:18:48 PM
That's what I thought ;)
Well, I just hope someone who knows better than I do (which isn't hard) about .htaccess will pass around here...
Title: Re: [htaccess] RewriteEngine
Post by: brainiac744 on November 13, 2005, 11:01:52 PM
I'm certainly no expert either, but I THINK I found your problem

RewriteRule ^(fr|en|es|nl)_([a-zA-Z]*).html /index.php?page=$2&lang=$1

That line ^^^^^ is missing a $, it should be this:

RewriteRule ^(fr|en|es|nl)_([a-zA-Z]*).html$ /index.php?page=$2&lang=$1


I THINK...I'm certainly no expert either ;)
Title: Re: [htaccess] RewriteEngine
Post by: Ben on November 13, 2005, 11:41:44 PM
Quote
RewriteEngine On

RewriteRule ^(fr|en|es|nl)_([a-zA-Z]*).html /index.php?page=$2&lang=$1
RewriteRule ^index.html$ /index.php [L]

The differance is the [L] at the end, which signals that it's the last rule.
Title: Re: [htaccess] RewriteEngine
Post by: Guide on November 15, 2005, 03:57:06 PM
Strange... I just tried both of those advise and it still didn't work. Any other suggestion?
I checked on another computer to be certain it wasn't a cache problem, but still no result but the infamous 404 page. What I find real abnormal is that I get no Server Error, as I usually do when I mess up with the RewriteEngine... Just the Error 404.
Title: Re: [htaccess] RewriteEngine
Post by: webzone (archived) on November 15, 2005, 08:42:22 PM
You only get a Server Error when your .htaccess and/or your RewriteRule are not written properly.

If you only get a 404 error, then it means that your rules can be parsed, but that the address you requested does not match any rewrite instruction (or existing file, of course).
Title: Re: [htaccess] RewriteEngine
Post by: Ben on November 15, 2005, 10:17:26 PM
QuoteRewriteEngine On
RewriteRule ^(fr|en|es|nl)_([a-zA-Z]+).html$ index.php?page=$2&lang=$1
RewriteRule ^index.html$ index.php [L]

Okay, several changes here. I changed * to +, removed the / before index.php in both rules, and added a $ after html in the first rule. I've tested it on my account and it seems to be working fine.
Title: Re: [htaccess] RewriteEngine
Post by: Guide on November 16, 2005, 08:13:43 AM
Great, it's working now!
Thanks to all of you :)