繁体   English   中英

.htaccess重写规则GET参数

[英].htaccess Rewrite Rules GET Parameter

我已经用调度程序在php中编写了一个Web应用程序,所以我想通过get参数将控制器和函数传递给index.php,但是要获取SEO URL,我想编写一些重写规则,但是我无法让它们正常工作。 这里举个例子。

网址: http : //api.domain.com/v1/这是index.php

DirectoryIndex index.php

RewriteEngine On

Options +FollowSymLinks
#Das explizite Setzen der Basis-URL f�r die weiteren Manipulation.
RewriteBase /v1/

#schlie�e existierende Dateien
RewriteCond %{REQUEST_FILENAME} !-f
#Ignoriere URL's die mit .htm enden
RewriteCond %{REQUEST_URI} !.+\.htm
#es erfolgt ein Aufruf ohne trailing slash
RewriteCond %{REQUEST_URI} !(.*)/$

#api events und mods
RewriteRule    ^Login/do/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/$    ?evt=Login&mod=_do&username=$1&password=$2&m=$3    [NC,L]    # Process to index

#Es wird gepr�ft, ob es sich um eine vorhandene Datei handelt.
RewriteCond %{REQUEST_FILENAME} !-f
#Es wird gepr�ft, ob es sich um ein vorhandenes Verzeichnis handelt.
RewriteCond %{REQUEST_FILENAME} !-d
#Verarbeite alles mit der index.php Datei.
RewriteRule (.*) index.php

我想要这样的URL: http ://api.domain.com/v1/Login/do/username/password/m/但我的php脚本未获得Login和_do参数! 这些重写规则有什么问题?

这是您的htaccess的较干净版本,应该可以使用

RewriteEngine On
RewriteBase /v1/

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]

RewriteRule ^Login/do/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/$ index.php?evt=Login&mod=_do&username=$1&password=$2&m=$3 [NC,L]

RewriteRule ^(.*)$ index.php [L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM