Php 漂亮的URL内部重定向到丑陋的URL

Php 漂亮的URL内部重定向到丑陋的URL,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,请参阅该链接: 我的问题: 这对我帮助很大,但如果链接看起来像这样会怎么样: 如何将其更改为:第二条规则将pretty url重定向回 RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index.php\?([^&=]+)=([^&\ ]+)&([^&=]+)=([^&\ ]+)(\ |$) [NC] RewriteRule ^ /%2/%4/? [R=302,L]. 我想就是这样 RewriteRule ^(.+)/?

请参阅该链接: 我的问题:

这对我帮助很大,但如果链接看起来像这样会怎么样:

如何将其更改为:第二条规则将pretty url重定向回

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index.php\?([^&=]+)=([^&\ ]+)&([^&=]+)=([^&\ ]+)(\ |$) [NC] RewriteRule ^ /%2/%4/? [R=302,L].
我想就是这样

RewriteRule ^(.+)/?$ /category.php?category=$1&id=$2 [QSA,NC,L] 
它不起作用。我必须重写^(+)/?$,但我不知道怎么写

我的代码:

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

# Redirect /category.php?category=something to /something

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?([^&=]+)=([^&\ ]+)
(\ |$) [NC]
RewriteRule ^ /%2? [R=302,L]

# Internally forward /something to /category.php?category=something
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/.]+)/?$ /index.php?page=$1 [QSA,NC,L]

# Redirect /category.php?category=something&id=ID to /something/ID
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?([^&=]+)=([^&\ 
]+)&([^&=]+)=([^&\ ]+)(\ |$) [NC]
RewriteRule ^ /%2\/%4/?  [R=302,L]

# Internally forward /something/ID to /category.php?category=something&id=ID
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/.]+)/?$ /index.php?page=$1 [QSA,NC,L]

注意:只有当您尝试迁移外部链接时,这才是合法的。也就是说,你以前有丑陋的URL,这些URL已经在外部网站上使用过,你想继续支持这些链接而不破坏它们。在任何其他情况下,您都不会这样做。注意:只有当您尝试迁移外部链接时,这才是合法的。也就是说,你以前有丑陋的URL,这些URL已经在外部网站上使用过,你想继续支持这些链接而不破坏它们。在任何其他情况下,您都不会这样做。