RewriteEngine ON
RewriteRule ^video$ video.php [L]
上面的線路作品
example.com/video被解釋為example.com/video.php
現在我需要example.com/video?id=5&s=lorem-ipsum
解釋為example.com/video/5/lorem-ipsum- 反之亦然
RewriteCond %{THE_REQUEST} video?id=([^\s&] )&s=([^\s&] ) [NC]
RewriteRule ^ %1/%2? [R=301,L]
RewriteRule ^([\w-] )/([\w-] )/?$ video?id=$1&s=$2 [L,QSA]
RewriteRule ^([\w-] )/([\w-] )/?$ video?/$1/$2 [L,QSA]
不起作用 - 在兩個方向上
請幫助
uj5u.com熱心網友回復:
通過您顯示的嘗試,請嘗試遵循 .htaccess 規則檔案。這些規則假設您想徹底重寫 index.php,您可以根據您的要求在第二組規則中更改 php 檔案名。
確保在測驗 URL 之前清除瀏覽器快取。
RewriteEngine ON
##External redirect Rules from here..
##Redirect 301 to example.com/video/5/lorem-ipsum from example.com/video?id=5&s=lorem-ipsum
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{THE_REQUEST} \s/(video)\?id=([^&]*)&s=(\S )\s [NC]
RewriteRule ^ /%1/%2/%3? [R=301,L]
##Internal rewrite for example.com/video?id=5&s=lorem-ipsum
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^video/([^/]*)/(.*)/?$ index.php?id=$1&s=$2 [QSA,NC,L]
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/472441.html
標籤:阿帕奇 .htaccess 改写 友好的网址 s3-重写规则
