开发者

.htaccess rewrite remove directory name from request

I am trying to make a redirect from a request like [http://test.site.com/pagename--city/] to something like [http://test.site.com/state/pagename--city/] and then back to [http://test.site.com/pagename--city/]. The 'state/pagename--city' are physical directories on the server. So if someone clicks on [http://test.site.com/pagename--city/] I need to execute [http://test.site.com/state/pagename--city/index.php] but the URL to remain [http://test.site.com/pagename--city/]. Any help appreciated. Thnx.

.htaccess file

Options +FollowSymlinks

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_URI} /(开发者_Python百科.*)--(.*)/?$
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&%{QUERY_STRING} [L]


Not very clear, is this what you are looking for?

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜