mod rewrite problem

This is a discussion on mod rewrite problem within the Apache Web Server forums, part of the Web Server and Related Forums category; I have a site hosted with godaddy that uses a database to hold content which is then dynamically loaded into ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-09-2008
Grouchy.Oldgit@googlemail.com
 
Posts: n/a
Default mod rewrite problem

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?
  #2 (permalink)  
Old 06-09-2008
HansH
 
Posts: n/a
Default Re: mod rewrite problem

<Grouchy.Oldgit@googlemail.com> schreef in bericht
news:edc59f35-e7ed-4774-9007-6a127f69093d@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


  #3 (permalink)  
Old 06-10-2008
Álvaro G. Vicario
 
Posts: n/a
Default Re: mod rewrite problem

Grouchy.Oldgit@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
--
  #4 (permalink)  
Old 06-11-2008
D. Stussy
 
Posts: n/a
Default Re: mod rewrite problem

<Grouchy.Oldgit@googlemail.com> wrote in message
news:edc59f35-e7ed-4774-9007-6a127f69093d@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]
>
> However, this still returns a "page cannot be found error".
>
> Any suggestions?


[L,R]

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


  #5 (permalink)  
Old 06-11-2008
D. Stussy
 
Posts: n/a
Default Re: mod rewrite problem

<Grouchy.Oldgit@googlemail.com> wrote in message
news:edc59f35-e7ed-4774-9007-6a127f69093d@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]
>
> However, this still returns a "page cannot be found error".
>
> Any suggestions?


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.


  #6 (permalink)  
Old 06-11-2008
HansH
 
Posts: n/a
Default Re: mod rewrite problem

"D. Stussy" <spam@bde-arc.ampr.org> schreef in bericht
news:g2nrif$kt6$1@snarked.org...
> <Grouchy.Oldgit@googlemail.com> wrote in message
> news:edc59f35-e7ed-4774-9007-6a127f69093d@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...ml#rewritebase

HansH


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:23 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0