htaccess重写了一个get参数



我已经有了Typo3 Flow.htaccess##TYPO3流量上下文设置#

# You can specify a default context by activating this option:
# SetEnv FLOW_CONTEXT Production
# If the root path is not the parent of the Web directory,
# TYPO3 Flow's root path must be specified manually:
# SetEnv FLOW_ROOTPATH /var/www/myapp/
#
# mod_rewrite configuration
#
<IfModule mod_rewrite.c>
# Enable URL rewriting
RewriteEngine On
# Set flag so we know URL rewriting is available
SetEnv FLOW_REWRITEURLS 1
# You will have to change the path in the following option if you
# experience problems while your installation is located in a subdirectory
# of the website root.
RewriteBase /

# Stop rewrite processing no matter if a package resource, robots.txt etc. exists or not
RewriteRule ^(_Resources/Packages/|robots.txt|favicon.ico) - [L]
# Stop rewrite process if the path points to a static file anyway
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
# Perform rewriting of persistent private resources
RewriteRule ^(_Resources/Persistent/[a-zA-Z0-9]+/(.+/)?[a-f0-9]{40})/.+(..+) $1$3 [L]
# Perform rewriting of persistent resource files
RewriteRule ^(_Resources/Persistent/.{40})/.+(..+) $1$2 [L]
# Make sure that not existing resources don't execute TYPO3 Flow
RewriteRule ^_Resources/.* - [L]
# Continue only if the file/symlink/directory does not exist
RewriteRule (.*) index.php
</IfModule>
<IfModule mod_negotiation.c>
# prevents Apache's automatic file negotiation, it breaks resource URLs
Options -MultiViews
</IfModule>
<IfModule mod_setenvif.c>
# Redirect authorization header when PHP is running as CGI
SetEnvIfNoCase Authorization "Basic ([a-zA-Z0-9+/=]+)" REMOTE_AUTHORIZATION=$0
</IfModule>
ErrorDocument 500 "<h1>Application Error</h1><p>The TYPO3 Flow application could not be launched.</p>"

所以我认为这是标准流htaccess。是否有可能定义自己的规则?

我的htaccess技能相当糟糕。我必须编辑什么来替换GET参数

show?path=

我的域看起来像http://domain.com/show?path=/test/test2

它应该看起来像http://domain.com/show/test/test2

提前感谢,关于

是的,你可以扩展.htaccess,如果你启用了mod_proxy,添加这一行就足够了(检查[p]标志的作用)

# Add this line
RewriteRule ^show/(.*)$ /show?path=/$1 [P]
# Continue only if the file/symlink/directory does not exist
RewriteRule (.*) index.php

但您应该使用Routing来处理这类事情——然后您将拥有由框架处理的uri构建器和重写。

如果您的path只是showAction中的字符串参数,则10添加到My/Package/Configuration/Routes.yaml(并在Flow子例程之上的主Configuration/Routes.yaml中设置子例程)

-
  name: 'show'
  uriPattern: 'show/{path}'
  defaults:
    '@package':    'My.Package'
    '@controller': 'Standard'
    '@action':     'show'
    '@format':     'html'
  appendExceedingArguments: true

若它是对象的属性,那个么在上面的链接中有一个例子。

唯一的问题是参数中的/(如"/test/test2")无法与上面的路由一起工作。。要处理包含/的参数,您可能需要创建自己的路由部件处理程序。

最新更新