Forum Moderators: phranque

Message Too Old, No Replies

Simple rewrite-rule gives 404 error?!

Hopefully someone can tell me what might be wrong

         

Augenfeind

11:42 am on Jun 19, 2009 (gmt 0)

10+ Year Member



Hello folks,

I'm just starting with mod_rewrite and am trying to do a simple rewriting using a small .htaccess:

RewriteEngine on
RewriteRule ^artists/(.*)$ [MY.DOMAIN.HERE...] [L,R]

That is I want to give all [MY.DOMAIN.HERE...] - requests the output of [MY.DOMAIN.HERE...]

But everithing I get is a 404 - File does not exist: /path/to/server/artists/SomeArtistsName

The .htaccess lives in the /artists - directory.

The .htaccess IS interpreted, as I first used UTF-8 with BOM, which led to another error...

Anyone has an advice for me? I thought this should be a very basic and simple task, but I'm not getting a useful result.

Best regards and thank you in advance,
Roman.

[edited by: Augenfeind at 11:44 am (utc) on June 19, 2009]

Augenfeind

12:04 pm on Jun 19, 2009 (gmt 0)

10+ Year Member



Problem solved: I just had to remove hte "artists/" from my "^artists/(.*)$"

jdMorgan

12:20 pm on Jun 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



By using a redirect (with a protocol, domain name, and [R] flag) on your rule, you are sending a response to the client (browser or robot) that says, "The resource you requested has moved. Asl for it again at this new URL."

This requires the clients to make a second HTTP request, and exposes your script path to the clients, and so negates any benefit of linking to and using your "friendly" URLs.

You would likely be happier using an internal rewrite instead of a redirect:


RewriteEngine on
RewriteRule ^artists/(.*)$ /artists.php?artist=$1 [L]

Jim