首页 > 解决方案 > 使用内部重定向重写漂亮的 url

问题描述

我正在尝试通过内部重定向来设置一个漂亮的 url http://test.agency.com/private
http://test.agency.com/index.html?//private

当我给R我的 htaccess 是

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} "^$"
RewriteRule ^(.*)$ /index.html?//$1 [QSA,L,R]

当它尝试维护漂亮的 url 并使用内部重定向时

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} "^$"
RewriteRule ^(.*)$ /index.html?//$1 [QSA,L,P]

它不工作,这些是我得到的日志

strip per-dir prefix: /var/www/html/agencytest/private -> 
private
[perdir /var/www/html/agencytest/] applying pattern '^(.*)$' to 
uri 
'private'
[perdir /var/www/html/agencytest/] rewrite 'private' -> 
'/index.html?//private'
split uri=/index.html?//private -> uri=/index.html, args=//private
[perdir /var/www/html/agencytest/] escaped URI in per-dir context 
for 
proxy, /index.html -> /index.html
[perdir /var/www/html/agencytest/] forcing proxy-throughput with  
http://agencytest.vignets.com/index.html
[perdir /var/www/html/agencytest/] go-ahead with proxy request 
proxy:http://agencytest.vignets.com/index.html?//private [OK]
[perdir /var/www/html/agencytest/] strip per-dir prefix: 
/var/www/html/agencytest/index.html -> index.html
[perdir /var/www/html/agencytest/] applying pattern '^(.*)$' to 
uri 
'index.html'
[perdir /var/www/html/agencytest/] pass through 
/var/www/html/agencytest/index.html

请注意private可以是任何字符串

标签: regexapachemod-rewriteurl-rewriting

解决方案


推荐阅读