繁体   English   中英

如何使用.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM