Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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
Javascript 当htacess将主页重定向到mydomain.com时,使用ajax内部链接到主页(/index)_Javascript_Ajax_.htaccess_Http Status Code 301 - Fatal编程技术网

Javascript 当htacess将主页重定向到mydomain.com时,使用ajax内部链接到主页(/index)

Javascript 当htacess将主页重定向到mydomain.com时,使用ajax内部链接到主页(/index),javascript,ajax,.htaccess,http-status-code-301,Javascript,Ajax,.htaccess,Http Status Code 301,我在Apache.htaccess文件中使用重定向将index.html中的所有流量发送到mydomain.com。为此,我使用以下方法: Options +FollowSymLinks RewriteCond %{THE_REQUEST} ^.*/index.html RewriteRule ^(.*)index.html$ http://www.mydomain.com/$1 [R=301,L] 我现在遇到的问题是,在使用AJAX调用中的内容时,使用到主页的相对路径 如果我想从/index

我在Apache.htaccess文件中使用重定向将index.html中的所有流量发送到mydomain.com。为此,我使用以下方法:

Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.mydomain.com/$1 [R=301,L]
我现在遇到的问题是,在使用AJAX调用
中的内容时,使用到主页的相对路径


如果我想从/index.html获取内容,我会得到一个404错误。我可以通过使用绝对路径来克服这个问题。”http://mydomain.com“,但是有没有一种方法我仍然可以使用到主页的相对路径?

就在我脑海中,我想说你的URL参数/锚没有经过重写。您可以使用QueryStringAppend
QSA
标志来解决这个问题,如下所示:

RewriteRule ^(.*)index.html$ http://www.mydomain.com/$1 [QSA,R=301,L]