Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道如何执行 htaccess 重写,如下所述。
domain.com/filename/testing123 --> domain.com/filename.php?/testing123
其中“文件名”是 php 文件的名称。这个“文件名”可以更改,“文件名”之后的任何内容都添加到“?”之后。
另一个例子是:
domain.com/abc/other/information/etc --> domain.com/abc.php?/other/information/etc
谢谢,
康纳
用于^([^/]+)匹配第一个之前的所有内容,将被附加/到其中.php,并(.*)匹配将在?via之后附加的所有其他内容$2。
^([^/]+)
/
.php
(.*)
?
$2
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !\.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)(.*)$ $1.php?$2 [L]