Advice for Getting mod_rewrite to Work

坚强是说给别人听的谎言 提交于 2019-12-11 17:19:38

问题


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:


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.



来源:https://stackoverflow.com/questions/3130779/advice-for-getting-mod-rewrite-to-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!