Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用.htaccess重写子文件夹_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php 如何使用.htaccess重写子文件夹

Php 如何使用.htaccess重写子文件夹,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,假设我有这个url: http://www.example.com/page http://www.example.com/page/another-page 我的.htaccess中有以下代码: RewriteEngine On RewriteRule ^([a-z]+)\/?$ index.php?pag=$1 [NC,L] 它可以工作,但如果我转到此url: http://www.example.com/page http://www.example.com/page/anoth

假设我有这个url:

http://www.example.com/page
http://www.example.com/page/another-page
我的.htaccess中有以下代码:

RewriteEngine On

RewriteRule ^([a-z]+)\/?$ index.php?pag=$1 [NC,L]
它可以工作,但如果我转到此url:

http://www.example.com/page
http://www.example.com/page/another-page
它将返回404

在my.htaccess的代码中,我得到了$\u 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]

不起作用
/page/a
url也不起作用吗?你能调整你的问题的标题,这样当其他人搜索
重写时它就会显示出来吗?如果不起作用,请同时检查你的mod_rewrite是否处于打开状态。。。例如:
在数组中('mod_rewrite',apache_get_modules())