Advice for Getting mod_rewrite to Work

2019-08-28 16:37发布

I am trying to make clean URLs. I have written a simple rule on the .htaccess file and I have been told that it should work. However, it does not. I was wondering if it might have something to so with mod_rewrite not being enabled.

I am using Network Solutions shared hosting. I called the company and was told that mod_rewrite is enabled by default on the hosting I have.

Any advice on how I can check to see if mod_rewrite is enabled? Also, I would appreciate any related advice.

Thanks in advance,

John

EDIT: I just posted this at Serverfault.com, but I'm hesitant to delete it here since I have a feeling it might get more views here. Let me know if I should delete it here as well. Thanks.

EDIT:

Below is my .htaccess file. I am getting a 404 error when I go to a URL that this should re-write.

RewriteEngine On
RewriteRule ^comments/([A-Za-z0-9-]+)-([0-9]+)?$ index.php?submissionid=$2 [NC,L]

1条回答
闹够了就滚
2楼-- · 2019-08-28 16:54

Try putting up a bad .htaccess file (i.e. random text) in a test folder. You should get all 500 errors from that folder. If not, .htaccess files are not enabled, and you'll have to get your hosting company to switch them on.

Then try a really simple rewrite rule:

RewriteEngine On
RewriteRule foo index.php

and see if that works. If you get a 500 error at this stage, mod_rewrite is probaby not enabled.

查看更多
登录 后发表回答