Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.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
在每个html或php url上显示index.php,而不更改url_Php_.htaccess_Url_Redirect - Fatal编程技术网

在每个html或php url上显示index.php,而不更改url

在每个html或php url上显示index.php,而不更改url,php,.htaccess,url,redirect,Php,.htaccess,Url,Redirect,在每个html或php url上显示index.php,而不更改url 例如,用户键入anything everything.html(.php)将显示index.php而不更改url 条件-主机上不存在的任何东西everything.html(.php) 像404重定向一样,在不更改url的情况下使用apache重写(如果您使用apache并有权访问服务器)。 来自的配方应该可以。欢迎使用SO。如果您在Apache Web服务器上运行您的网站,则可以使用来实现这一点。下面是一个.htacces

在每个html或php url上显示index.php,而不更改url

例如,用户键入anything everything.html(.php)将显示index.php而不更改url

条件-主机上不存在的任何东西everything.html(.php)

像404重定向一样,在不更改url的情况下使用apache重写(如果您使用apache并有权访问服务器)。
来自的配方应该可以。

欢迎使用SO。如果您在Apache Web服务器上运行您的网站,则可以使用来实现这一点。下面是一个
.htaccess
文件的示例,您必须将其放置在网站的根目录中

# switch on mod_rewrite
RewriteEngine On

# redirect all non-www request to www
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# rewrite all physical files and folders
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d

# add all exceptions that should not be redirected
RewriteCond %{REQUEST_URI} "/layout/" [OR]
RewriteCond %{REQUEST_URI} "/javascript/" [OR]
RewriteCond %{REQUEST_URI} "/content"

# and finally pass everything to the index.php as a parameter
RewriteRule .* - [L]
RewriteRule (.*) index.php?value=$1 [QSA]
这将执行以下操作:

  • 如果用户请求,他将被禁止
  • 请求domain.com/hello/world.html将在index.php文件中以一个现有的
    $\u GET['value']
    结束,该文件保存
    hello/world.html
    ,然后可以进一步处理

正在工作,但为每个页面显示相同的回显,需要根据需要使用不同的php回显urls@kritprim对不起,我不太明白你的评论。您的意思是,每个请求都需要一个不同的PHP文件,例如
/hello
将被重定向到
hello.PHP
?用于echo urlof currunt PageRequire的PHP文件对于allpagesex来说需要不同的echo。这是php