Dav*_*Fes 1 html php apache .htaccess mod-rewrite
mod_rewrite的新手.我只想做这样的事情:
# Turn on the rewriting engine
RewriteEngine On
# use item php page to show the item
RewriteRule ^parts/./[.]$ parts/item.php?id=$1 [NC]
Run Code Online (Sandbox Code Playgroud)
所以当一个人输入example.com/parts/anything/anything时,URL就会转到
example.com/parts/item.php?id=the2ndanything
根据我的理解,这个时期意味着任何角色.此外,我试图在句点之后添加一个+(这应该意味着什么),但仍然无效.
顺便说一句,我在一个临时URL,因为我还没有更改我以前的网络主机,因此我的实际完整网址中有一个〜.我希望这不是mod_rewriting的问题,因此是阻止它工作的问题..htaccess文件位于根网站的index.html中.
这.
确实意味着任何角色,但你必须遵循它+
(一个或多个)或*
(零个或多个),你必须捕获它()
以用作$1
.使用[^/]+
匹配所有字符,但不包括/
匹配,但之后没有捕捉到第一个目录parts/
.
RewriteEngine On
# (.*) captures the second "anything" in $1
RewriteRule ^parts/[^/]+/(.*)$ parts/item.php?id=$1 [L]
Run Code Online (Sandbox Code Playgroud)