Php .htaccess重写规则仅影响目录/SPA HTML5 pushState友好URL
最近转到Media Temple,它通过发送完整路径而不是相对路径打破了我所有精彩的重写规则,因此我需要对我的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
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/