Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.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重写规则仅影响目录/SPA HTML5 pushState友好URL_Php_Html_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php .htaccess重写规则仅影响目录/SPA HTML5 pushState友好URL

Php .htaccess重写规则仅影响目录/SPA HTML5 pushState友好URL,php,html,apache,.htaccess,mod-rewrite,Php,Html,Apache,.htaccess,Mod Rewrite,最近转到Media Temple,它通过发送完整路径而不是相对路径打破了我所有精彩的重写规则,因此我需要对我的mod_rewrite 目前的情况是: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !index RewriteRule (.*) index.php [L] RewriteRule ^www/ ind

最近转到Media Temple,它通过发送完整路径而不是相对路径打破了我所有精彩的重写规则,因此我需要对我的
mod_rewrite

目前的情况是:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.php [L]
RewriteRule ^www/ index.php [L]
我的文件夹和URL结构,其中真实文件夹以粗体显示:

/

/www

/www/experiences

/www/experiences/projectslug,js处理

/www/project files folder/css等

/assets/js、css等


js处理的/www/www/experiences/project slug成功重写到/index.php,但js处理的/www/experiences/project slug请求的资产也被重写到/index.php,这就是问题所在

那么,是否可以告诉重写规则只影响目录中的文件夹,或者我需要更好的条件/规则


谢谢

事实上,您的上一条规则是罪魁祸首,并导致css/js加载错误:

RewriteRule ^www/ index.php [L]
将代码替换为以下内容:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule ^ index.php [L]

RewriteRule ^www/?$ index.php [L,NC]

^www/?$
将只匹配
/www/
而不是
/www/

实际上,您的上一条规则是罪魁祸首,并导致css/js加载错误:

RewriteRule ^www/ index.php [L]
将代码替换为以下内容:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule ^ index.php [L]

RewriteRule ^www/?$ index.php [L,NC]
^www/$
将只匹配
/www/
,而不匹配
/www/