News:

LVCS.NET offers low cost domain registration services.

Main Menu

htaccess -> mod_rewrite doesnt work

Started by styx, March 03, 2007, 02:58:15 PM

Previous topic - Next topic

styx

Hey,

I am new to mod_rewriting, so I read some guides. The I tested a very simple one:
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [nc]


But it doesn't work at all?

They say I normally have to add this line in front:
Options +FollowSymlinks
But options is disabled on this host, so I removed it.

The script just doesn't do what I want :/, while I followed the guide correctly (link to guide: here).

Can you please help me out?

brainiac744

When you say that it doesn't work at all, are you getting a 500 internal server error when that is in the .htaccess, or is there another problem?

styx

Quote from: brainiac744 on March 04, 2007, 03:49:03 AM
When you say that it doesn't work at all, are you getting a 500 internal server error when that is in the .htaccess, or is there another problem?

If I add the Options line in it, I get a 500 ... but else it just doesn't do anything. If I got to an HTML-page, it doesn't show the PHP one :/.

brainiac744

Do you get a 404 error then?

Notice that rule is only going to rewrite .htm files to .php files, not .html ones, so be sure that you're trying a filename that will be rewritten.

Otherwise you'll have to wait for somebody who knows a bit more about mod_rewrite than me, because I don't see an error in that code.

styx

Of course I used a HTML-file ;).
If I try to go to index.php it will give an error, and index.htm just shows normal, with the htm-extension :/.

admin

Please provide your URL or account username for further assistance.

(You can also use the Contact Form to provide this information to us)

Thank you,
FreePgs.com Admin

styx

Hey,

Thanks for your response :). I will use the contact form for this problem ;).

admin

I created the .htaccess file and it seems to work (it does what the rules tell it to do)

Note the following exceptions:

The flag should be [NC] not [nc].  (Please note that these two values are completely different)

The proper file would be (based on your original file)

RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [NC]

In the contact request you stated .html but here you wrote .htm, I am not sure which you intend to use.  The file created in your account uses .html

If you intend to also have .html files in your account, you will need to use RewriteCond to setup a condition to not rewrite if the file exists.  Otherwise, you should be fine.

The Options directive does not need to be included as that option is already set on this system.

Thank you,
FreePgs.com Admin