[英]Rewrite a url string to corresponding folders
我想擁有漂亮的網址,同時隱藏我的文件夾結構,
我希望第一個網址指向第二個網址,
我嘗試跟隨,但沒有成功;
RewriteRule ^image\/([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)$ img\/$1\/$2\/$3
我該如何使用htaccess?
您的正則表達式需要匹配正則表達式模式中的下划線:
RewriteEngine On
# disable direct access:
RewriteCond %{THE_REQUEST} \s/+img/[^/]+/[^/]+/.+?\.jpg\s [NC]
RewriteRule ^ - [L,R=404]
RewriteRule ^image/([^_]+)_([^_]+)_(.+?\.jpg)$ /img/$1/$2/$3 [L,NC,R=302]
在您的第一個URL中,您有_
not /
。 最后是.jpg
(帶有.
)
RewriteRule ^image/([a-z0-9]+)_([a-z0-9]+)_([a-z0-9.]+)$ img/$1/$2/$3 [NC,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.