php .htaccess文件不生效,php – .htaccess重写子目录不起作用

我想重写我的网址:

http://mysite.com/index.php?node=home&photoID=10

至:

http://mysite.com/home/10

目前,仅为

http://mysite.com/home

我用

RewriteRule ^([^/]*)$index.php/?node=$1 [L]

但是当我尝试使用时

RewriteRule ^([^/]*)/([^/]*)$index.php/?node=$1&id=$2 [L]

它似乎没有正确加载我的页面,页面没有样式或任何东西.

(另外,我的.htaccess文件的顶部有:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

如果我只是去mysite.com/home它显示404找不到.如果不总是有子页面,我该怎么做?

解决方法:

首先要让你的.htaccess规则如下:

Options +FollowSymLinks -MultiViews

# Turn mod_rewrite on

RewriteEngine On

RewriteBase /

## If the request is for a valid directory

RewriteCond %{REQUEST_FILENAME} -d [OR]

## If the request is for a valid file

RewriteCond %{REQUEST_FILENAME} -f [OR]

## If the request is for a valid link

RewriteCond %{REQUEST_FILENAME} -l

## don't do anything

RewriteRule ^ - [L]

RewriteRule ^([^/]+)/([^/]+)/?$index.php/?node=$1&id=$2 [L,QSA]

RewriteRule ^([^/]+)/?$index.php/?node=$1 [L,QSA]

然后确保在< head>之间的页面顶部添加此行.和< / head>:

标签:php,htaccess

来源: https://codeday.me/bug/20190630/1332027.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值