![](/img/trans.png)
[英]how to redirect to a subfolder and then rewrite subfolder link to root in htaccess?
[英]How to rewrite subfolder with .htaccess
可以說我有這個網址:
http://www.example.com/page
這段代碼在我的.htaccess文件中:
RewriteEngine On
RewriteRule ^([a-z]+)\/?$ index.php?pag=$1 [NC,L]
它有效,但是如果我轉到此URL:
http://www.example.com/page/another-page
它將返回404。
在我的.htaccess文件中,我得到了$ _GET ['page']。
基本上,我想獲得的URL為:
index.php?pag=page/another-page
並且不返回404。
我通常使用這種模式:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.