English 中文(简体)
为什么赢得这种简单的《礼约》工作?
原标题:Why won t this simple RewriteRule work?

这应当是简单的,但我不能说出。 我有这种非常简单的改写规则,只是想工作。 这是“htaccess”案的全部内容。

RewriteEngine On
RewriteRule ^([A-Za-z0-9-_/.]+)/?$ index.php?page=$1 [L]

如果我称之为URL域.com/foo,那么它就应当将其重新编成索引。 但是,它将其重新编成索引:php?page=index.php。 我已尝试过多次危房:

  • index.php?page=foo
  • index.php
  • /foo
  • /

在所有情况下,PHP都像将网页放在“指数.php”上。 它没有指数错误。 php是因为我取代了整个指数内容。 带有简单对应页数的文字的php,仍然作为指数出现。 php。

如果我在这里错失,任何帮助都会变得非常麻烦!

增 编

Adrian

最佳回答

任何理由,如:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L]

如果你试图将现有网页重新编成,那么!-f将考虑到( 如果档案不存在,如果目录不存在,则re-write

问题回答

我认为这是你所期望的。 不幸的是,如果URL有其他的GET论点(IE, /about/url/path?page=1),那么它确实运转良好。

RewriteEngine On
RewriteRule ^(.*)$ index.php?page=$1 [L]

www.un.org/Depts/DGACM/index_spanish.htm 更好的想法:

RewriteEngine On
RewriteRule ^(.*)$ index.php [L,QSA]

QSA旗帜将推进GET params,然后以指数表示。 php将$_SERVER[RequestST_URI]parse_url转至请求。

http://d.apache.org/docs/1.3/mod/mod_rewrite.html http://http://d.apache.org/docs/1.3/mod/mod_rewrite.html:

 qsappend|QSA  (query string append)
This flag forces the rewriting engine to append a query string part
in the substitution string to the existing one instead of replacing it.
Use this when you want to add more data to the query string via a rewrite rule.




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签