Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mod rewrite problem

1 view
Skip to first unread message

Grouchy...@googlemail.com

unread,
Jun 9, 2008, 12:57:37 PM6/9/08
to
I have a site hosted with godaddy that uses a database to hold content
which is then dynamically loaded into a fixed template by calling the
url such as mydomain.com/content.php?artid=3 etc.

It would be nice if users could enter urls as mydomain.com/articles/3
etc which I believe is achievable with apache mod rewrite. I therefore
added an .htaccess file containing:

RewriteEngine on
RewriteRule ^articles/([^/\.]+)/?$ content.php?artid=$1 [L]

When this didn't work I googled the problem to find the suggestion
that with godaddy it was necessary to add an additional command, ie:

Options -MultiViews
RewriteEngine on
RewriteRule ^articles/([^/\.]+)/?$ content.php?artid=$1 [L]

However, this still returns a "page cannot be found error".

Any suggestions?

HansH

unread,
Jun 9, 2008, 1:09:44 PM6/9/08
to
<Grouchy...@googlemail.com> schreef in bericht
news:edc59f35-e7ed-4774...@w34g2000prm.googlegroups.com...

>I have a site hosted with godaddy that uses a database to hold content
> which is then dynamically loaded into a fixed template by calling the
> url such as mydomain.com/content.php?artid=3 etc.
>
> It would be nice if users could enter urls as mydomain.com/articles/3
> etc which I believe is achievable with apache mod rewrite. I therefore
> added an .htaccess file containing:
>
> RewriteEngine on
> RewriteRule ^articles/([^/\.]+)/?$ content.php?artid=$1 [L]
>
> When this didn't work I googled the problem to find the suggestion
> that with godaddy it was necessary to add an additional command, ie:
>
> Options -MultiViews
> RewriteEngine on
> RewriteRule ^articles/([^/\.]+)/?$ content.php?artid=$1 [L]
>
Your .htaccess is at the root of the site, not in the folder articles?
If it is in the folder -I'ld prefere- add to it:
RewriteBase /

Are you sure this .htaccess is accessed?
Just to test its use add a line holding the single word 'bogus' :
a crashing site is proof of usage !


HansH


"Álvaro G. Vicario"

unread,
Jun 10, 2008, 3:16:16 AM6/10/08
to
Grouchy...@googlemail.com escribió:

> I have a site hosted with godaddy that uses a database to hold content
> which is then dynamically loaded into a fixed template by calling the
> url such as mydomain.com/content.php?artid=3 etc.
>
> It would be nice if users could enter urls as mydomain.com/articles/3
> etc which I believe is achievable with apache mod rewrite. I therefore
> added an .htaccess file containing:
>
> RewriteEngine on
> RewriteRule ^articles/([^/\.]+)/?$ content.php?artid=$1 [L]

This works fine for me, given that the URL is
http://mydomain.com/articles/3 or http://mydomain.com/articles/3/ and
there's a content.php script.

Try to have a look at Apache's error log (you may need to enable it in
Godaddy's control panel).

Also, is this your full .htaccess file?


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--

D. Stussy

unread,
Jun 10, 2008, 11:41:30 PM6/10/08
to
<Grouchy...@googlemail.com> wrote in message
news:edc59f35-e7ed-4774...@w34g2000prm.googlegroups.com...

[L,R]

You're rewriting a URL to a URL, not to a filename, so you need to re-inject
it by redirection.


D. Stussy

unread,
Jun 11, 2008, 2:27:08 AM6/11/08
to
<Grouchy...@googlemail.com> wrote in message
news:edc59f35-e7ed-4774...@w34g2000prm.googlegroups.com...

Scratch my prior answer (although it may still apply). I see an error with
your rule. Try:

RewriteRule ^/articles/([^/\.]+)/?$ content.php?artid=$1 [L]

You need a leading slash on the URI supplied by the user.


HansH

unread,
Jun 11, 2008, 3:45:51 AM6/11/08
to
"D. Stussy" <sp...@bde-arc.ampr.org> schreef in bericht
news:g2nrif$kt6$1...@snarked.org...

> <Grouchy...@googlemail.com> wrote in message
> news:edc59f35-e7ed-4774...@w34g2000prm.googlegroups.com...
>> RewriteEngine on
>> RewriteRule ^articles/([^/\.]+)/?$ content.php?artid=$1 [L]
>>
>> However, this still returns a "page cannot be found error".
>>
> Scratch my prior answer (although it may still apply). I see an error
> with
> your rule. Try:
>
> RewriteRule ^/articles/([^/\.]+)/?$ content.php?artid=$1 [L]
>
> You need a leading slash on the URI supplied by the user.
>
The leading slash is NOT to be used in .htaccess
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritebase

HansH


0 new messages