现代重写了的.htaccess
我的网址目前是这样的:http://www.example.com/?content=contact.php
现代重写了的.htaccess
但我希望用户在URL栏中输入以下内容:http://www.example.com/contact.php
我将此添加到我的.htaccess文件:
RewriteEngine On
RewriteRule ^([^/]*)$ /?content=$1 [L]
但我现在收到此错误:
内部服务器错误或
服务器遇到内部错误或配置错误,并且 无法完成您的请求。
请联系服务器管理员,[没有给出地址],并通知 他们发生错误的时间,以及您可能已经完成的任何可能导致错误的事情 。
有关此错误的更多信息可能在服务器错误 日志中可用。
的Apache/2.2.14(Ubuntu的)在www.example.com服务器端口80
我在做什么错?
尝试像这样我假设contact.php是不是实际的文件,
RewriteEngine on
RewriteRule ^(.*)$ ?content=$1 [QSA,L]
这应该工作
RewriteRule ^(.*)$ index.php?content=$1
此规则重定向所有的请求的index.php和传递获取变量“内容”。
例如:?
http://www.example.com/contact.php - >含量= contact.php
http://www.example.com/some/folder/ - >含量=一些/文件夹/
这会打开'http:// www.example.com/contact.php'而不是打开'http:// www.example.com'并设置'content = contact.php'。你有其他想法吗? – David
正如你所说:'但我希望用户在URL字段中具有以下内容:http://www.example.com/contact.php' –
问题是如果'example.com/contact.php'如果打开文件'/ contact.php'因为它存在,但它应该打开'example.com /'并设置GET参数'content = contact.php'。 – David
这将打开'http://www.example.com/ contact.php“而不是打开”http:// www.example.com“并设置”content = contact.php“。你有其他想法吗? – David
请尝试编辑! –