.htaccess重写从请求中删除目录名

.htaccess重写从请求中删除目录名,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我正在尝试从以下请求重定向[http://test.site.com/pagename——城市/]类似[http://test.site.com/州/页面名--城市/],然后返回[http://test.site.com/pagename--city/]. “state/pagename--city”是服务器上的物理目录。所以如果有人点击[http://test.site.com/pagename--city/]我需要执行[http://test.site.com/state/pagename-

我正在尝试从以下请求重定向[http://test.site.com/pagename——城市/]类似[http://test.site.com/州/页面名--城市/],然后返回[http://test.site.com/pagename--city/]. “state/pagename--city”是服务器上的物理目录。所以如果有人点击[http://test.site.com/pagename--city/]我需要执行[http://test.site.com/state/pagename--city/index.php]但URL仍然存在[http://test.site.com/pagename--city/]. 谢谢你的帮助。Thnx

.htaccess文件

Options +FollowSymlinks

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_URI} /(.*)--(.*)/?$
RewriteCond %{REQUEST_URI} !/state/
RewriteRule .* http://%{HTTP_HOST}/state%{REQUEST_URI} [L]

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


RewriteRule .* page.php?&[|]v1||%{REQUEST_URI}[|]v2||-[|]v3||%{HTTP_HOST}[|]v4||%{REQUEST_FILENAME}[|]v5||EOL[~|~]= [QSA,L]

不太清楚,这是你要找的吗

RewriteRule ^([^-]+)--(.+)$    /state/$1--$2/index.php

不完全是,我会尽量提供更多细节。例如,我在我的站点上有一个这样的链接[但在服务器上我有一个这样的物理目录结构/state/pagename--city[那么我给出的应该是完全相同的:)抱歉没有工作:|我得到一个500错误。这是我的.htaccess文件
Options+FollowSymlinks RewriteBase上的重写引擎/RewriteCond%{REQUEST\u URI}^/(.*)-(.*)/?$RewriteRule^(.+)-(.+)$/state/$1--$2/index.php[L]RewriteCond%{REQUEST\u FILENAME}!-RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-l RewriteRule.*page.php?&[|]v1 | |{REQUEST_URI}[|]v2 | |-[|]v3 | |{HTTP|主机}[|]v4 |{REQUEST|文件名}[|]v5 | v5 | | | EOL[| QSA,l]
尝试一次。删除rewriter cond后,我仍然感觉不执行重写规则。{REQUEST\u URI}/(.*)-(.*)/?$RewriteCond%{REQUEST\u URI}!/state/RewriteRule.*http://%{http\u HOST}/state%{REQUEST\u URI}[L]这会将我重定向到[/state/pagename--city/index.php],但我不知道如何从URL中删除“state”
RewriteRule ^(.*)--(.*)$ /state/$1--$2/index.php&%{QUERY_STRING} [L]