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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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? |
|
|||
|
<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 |
|
|||
|
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 -- |
|
|||
|
<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. |
|
|||
|
<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. |
|
|||
|
"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 |