Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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
Index.php使用BASEURL连接到内部页面连接问题htaccess_Php_.htaccess - Fatal编程技术网

Index.php使用BASEURL连接到内部页面连接问题htaccess

Index.php使用BASEURL连接到内部页面连接问题htaccess,php,.htaccess,Php,.htaccess,我在将内部页面连接到index.php文件时遇到问题。它使用BASEURL 有一段代码丢失了(在.htaccess文件中),基本上是说当您请求诸如/about-us之类的内部页面时调用index.php 代码段中有重写条件和重写规则 RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php RewriteRule ^index\.php$ / [L,R=301] RewriteCond %{HTTP_HOS

我在将内部页面连接到index.php文件时遇到问题。它使用BASEURL

有一段代码丢失了(在.htaccess文件中),基本上是说当您请求诸如/about-us之类的内部页面时调用index.php

代码段中有重写条件和重写规则

 RewriteEngine On
 RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
 RewriteRule ^index\.php$ / [L,R=301]

 RewriteCond %{HTTP_HOST} ^www\.website\.com$ [NC]
 RewriteRule ^(.*)$ http://www.website.com/$1 [L,R=301

我知道这是假设将所有URL从非www指向www。但它的格式与此类似。

将其放入根目录中的.htaccess filer中。将任何不存在的url重写为index.php

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php

将其放入根目录中的.htaccess文件管理器中。将任何不存在的url重写为index.php

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php
如果您知道
htacces
重定向,则使用为您创建重定向条件。如果您在apache配置中启用了
SymLinks
,则还可以使用以下代码

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
如果您知道
htacces
重定向,则使用为您创建重定向条件。如果您在apache配置中启用了
SymLinks
,则还可以使用以下代码

Options +FollowSymLinks
RewriteEngine On

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

Post your code snipletPost your code snipletThe index.php仍在工作,但将其放入htaccess不会破坏页面,对吗?我是htaccess的新手。不,只是重定向规则将所有请求指向您的
index.php
,然后您的
index.php
可以告诉您如何处理该规则。如果该规则不起作用,删除它将逆转更改正确吗?index.php仍在工作,但是把它放在htaccess中不会破坏页面,是吗?我是htaccess的新手。不,只是重定向规则会将所有请求指向您的
index.php
,然后您的
index.php
可以告诉您如何处理该规则。如果该规则不起作用,删除它将逆转更改,对吗?