有关使mod_rewrite生效的建议 [英] Advice for Getting mod_rewrite to Work

查看:81
本文介绍了有关使mod_rewrite生效的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建干净的URL.我在.htaccess文件上写了一个简单的规则,并被告知它应该可以工作.但是,事实并非如此.我想知道在未启用mod_rewrite的情况下是否可以解决问题.

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.

我正在使用网络解决方案共享主机.我打电话给该公司,并被告知默认情况下,在我拥有的主机上启用了mod_rewrite.

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.

关于如何检查是否启用了mod_rewrite的任何建议?另外,我将不胜感激任何相关的建议.

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

预先感谢

约翰

我刚刚在Serverfault.com上发布了此内容,但是由于我感觉它可能在这里获得更多观看,因此我很犹豫在此处将其删除.让我知道是否也应该在这里删除它.谢谢.

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.

下面是我的.htaccess文件.当我转到应重写的URL时,出现404错误.

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]

推荐答案

尝试在测试文件夹中放置错误的.htaccess文件(即随机文本).您应该从该文件夹中获得所有500个错误.如果没有,则不会启用.htaccess文件,您必须让托管公司将其打开.

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

,看看是否可行.如果在此阶段出现500错误,则可能未启用mod_rewrite.

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

这篇关于有关使mod_rewrite生效的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆