删除网站的PHP扩展与htaccess的 [英] Remove php extension of website with htaccess

查看:185
本文介绍了删除网站的PHP扩展与htaccess的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站这些链接:

I have these links on my website:

http://crw4u.be/werkgever.php
(我只能加在我的问题2个网址,因为我是一个的n00b)

http://crw4u.be/werkgever.php (I can only add 2 urls in my question, since i'm a n00b)

我添加了一个code到htaccess的,所以我可以访问这些页面,而不PHP:

I added a code to htaccess so I can access these pages without the php:

http://crw4u.be/werkgever

它正常工作与此code:

It works fine with this code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

但我用某种形式在我的PHP文件:

Yet I use certain forms in my php files:

<form name="planning" enctype="multipart/form-data" method="post" action="email/index.php">

和htaccess的与添加的code发送表单时遇到错误:

And I'm getting errors when sending the form with the added code in htaccess:

未找到
  所请求的URL /电子邮件/在此服务器上找到。

Not Found. The requested URL /email/ was not found on this server.

有谁知道如何去适应这个code?我一直在寻找和测试,但似乎无法来解决这个问题。

Does anyone knows how to adapt this code? I've been searching and testing, but can't seem to solve this.

高AP preciated!

Highly appreciated!

托马斯

推荐答案

试试这个规则: -

Try this Rule:-

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

下面是规则是如何工作的基本描述: -

Here is basic description for how rules are working:-

普通防爆pressions

. (any character)
* (zero of more of the preceding)
+ (one or more of the preceding)
{} (minimum to maximum quantifier)
? (ungreedy modifier)
! (at start of string means "negative pattern")
^ (start of string, or "negative" if at the start of a range)
$ (end of string)
[] (match any of contents)
- (range if used between square brackets)
() (group, backreferenced group)
| (alternative, or)
\ (the escape character itself)

使用常规的前pressions,也可以搜索各种模式中的URL并重写他们时,他们匹配

Using regular expressions, it is possible to search for all sorts of patterns in URLs and rewrite them when they match

标记

标记被添加到重写规则的结尾告诉Apache如何跨pret和处理规则。它们可以被用来告诉Apache处理规则为不区分大小写,停止处理规则,如果当前的一个相匹配,或各种其他选项。他们是用逗号分隔,并包含在方括号内。这里的标志的列表,以及它们的含义。

Flags are added to the end of a rewrite rule to tell Apache how to interpret and handle the rule. They can be used to tell apache to treat the rule as case-insensitive, to stop processing rules if the current one matches, or a variety of other options. They are comma-separated, and contained in square brackets. Here's a list of the flags, with their meanings.

C (chained with next rule)
CO=cookie (set specified cookie)
E=var:value (set environment variable var to value)
F (forbidden - sends a 403 header to the user)
G (gone - no longer exists)
H=handler (set handler)
L (last - stop processing rules)
N (next - continue processing rules)
NC (case insensitive)
NE (do not escape special URL characters in output)
NS (ignore this rule if the request is a subrequest)
P (proxy - i.e., apache should grab the remote content specified in the substitution section and return it)
PT (pass through - use when processing URLs with additional handlers, e.g., mod_alias)
R (temporary redirect to new URL)
R=301 (permanent redirect to new URL)
QSA (append query string from request to substituted URL)
S=x (skip next x rules)
T=mime-type (force specified mime type)

例外和特殊情况

重写条件可以在几个不同的方式进行测试 - 它们不需要被视为常规前pression型态,虽然这是他们所用的最常见的方式。这里有多种方式重写conditons可以加工

Rewrite conditions can be tested in a few different ways - they do not need to be treated as regular expression patterns, although this is the most common way they are used. Here are the various ways rewrite conditons can be processed:

<Pattern (is test string lower than pattern)
>Pattern (is test string greater than pattern)
=Pattern (is test string equal to pattern)
-d (is test string a valid directory)
-f (is test string a valid file)
-s (is test string a valid file with size greater than zero)
-l (is test string a symbolic link)
-F (is test string a valid file, and accessible (via subrequest))
-U (is test string a valid URL, and accessible (via subrequest))

希望它会帮助你:)

Hope it will help you :)

这篇关于删除网站的PHP扩展与htaccess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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