从rewriterule中排除网址

时间:2013-08-28 05:55:09

标签: apache .htaccess mod-rewrite

我必须为htaccess创建新规则。我写的。但我发现WSDL存​​在问题。当我使用新规则时,我遇到了与WSDL连接的问题。我不知道原因。但我必须解决它。

我可以用htaccess写一些内容,例如(伪代码):

if (http://www.mywebsite.com/mywebaplication/src/webServiceInstances.php?someGetParam) {
   RewriteRule ^([^\/]*)$ index.php?route=$1 [QSA]
} else {
   (RewriteRule...)

    RewriteRule ^([a-zA-Z]+)\.(html|xml|json|jhtml)$ public/index.php?module=$1&controller=Index&action=index&format=$2  [QSA]
    RewriteRule ^([a-zA-Z]+)$ public/index.php?module=$1&controller=Index&action=index&format=html  [QSA]
}

感谢回复。

编辑:这是我的全部重写

<IfModule mod_rewrite.c>
RewriteEngine On

#php public/index.php -mconfigure
RewriteBase /webaplication/src/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^\/]*)$ index.php?route=$1 [QSA]

</IfModule>

这是我全新的重写

<IfModule mod_rewrite.c>
 RewriteEngine On

#php public/index.php -mconfigure
RewriteBase /mywebaplication/src/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#new way:   module     controller   method           format

RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/([a-zA-Z]+)\.(html|xml|json|jhtml)$ public/index.php?module=$1&controller=$2&action=$3&format=$4  [QSA]
RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/([a-zA-Z]+)$ public/index.php?module=$1&controller=$2&action=$3&format=html  [QSA]

RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)\.(html|xml|json|jhtml)$ public/index.php?module=$1&controller=$2&action=index&format=$3  [QSA]
RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)$ public/index.php?module=$1&controller=$2&action=index&format=html  [QSA]

RewriteRule ^([a-zA-Z]+)\.(html|xml|json|jhtml)$ public/index.php?module=$1&controller=Index&action=index&format=$2  [QSA]
RewriteRule ^([a-zA-Z]+)$ public/index.php?module=$1&controller=Index&action=index&format=html  [QSA]

#old way(this works for wsdl)
RewriteRule ^([^\/]*)$ index.php?route=$1 [QSA]

1 个答案:

答案 0 :(得分:1)

用以下代码替换所有代码:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /webaplication/src/

RewriteRule ^(webServiceInstances\.php)$ index.php?route=$1 [QSA,L,NC]

# set default FMT to html
SetEnvIf Request_URI "^" FMT=html
# if a format is provided in URI then overwrite default FMT
SetEnvIf Request_URI "\.([^.]+)$" FMT=$1

RewriteRule ^([^/]+)/([^/]+)/([^/.]+)(?:\.(?:html|xml|json|jhtml)|/?)$ public/index.php?module=$1&controller=$2&action=$3&format=%{ENV:FMT} [NC,L,QSA]

RewriteRule ^([^/]+)/([^/.]+)(?:\.(?:html|xml|json|jhtml)|/?)$ public/index.php?module=$1&controller=$2&action=index&format=%{ENV:FMT} [L,NC,QSA]

RewriteRule ^([^/.]+)(?:\.(?:html|xml|json|jhtml)|/?)$ public/index.php?module=$1&controller=Index&action=index&format=%{ENV:FMT} [L,NC,QSA]