[英]PHP .htaccess redirect to a folder
我有PHP .htaccess来管理用户个人资料,如下所示:
http://example.com/user?=blabla
成为
http://example.com/blabla
这是.htaccess文件
Options -Multiviews
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?user=$1
RewriteRule ^([a-zA-Z0-9_-]+)$ post.php?user=$1
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/home/.*$ index.php [QSA]
现在我要这样:
http://example.com/blabla/post/
帖子是一个文件夹。
我尝试在根文件夹中进行文件夹发布,但仍然错误。 但是,当我尝试键入此URL时,请http://example.com/user/post运行OK。
我要的是用户可以打开http://example.com/blabla/post/
您可以使用以下规则:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^home/?$ index.php [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.+?)/?$ $1\.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/?$ user.php?user=$1 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.