Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.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
htaccess没有在index.php页面或默认页面上重定向我_Php_.htaccess_Redirect - Fatal编程技术网

htaccess没有在index.php页面或默认页面上重定向我

htaccess没有在index.php页面或默认页面上重定向我,php,.htaccess,redirect,Php,.htaccess,Redirect,当我尝试继续时,它仍然在specification.php页面上重定向我,而不是在index.php页面上重定向我 现在,我在我的主页上输入 这是我的完整密码 Options +FollowSymLinks -MultiViews -Indexes <IfModule mod_rewrite.c> DirectoryIndex index.php RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond

当我尝试继续时,它仍然在specification.php页面上重定向我,而不是在index.php页面上重定向我

现在,我在我的主页上输入

这是我的完整密码

Options +FollowSymLinks -MultiViews -Indexes

<IfModule mod_rewrite.c>

DirectoryIndex index.php

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

ErrorDocument 404 404error.php

RewriteRule ^([A-Za-z0-9-]+)?$ specification.php?url=$1 [L]

RewriteRule ^news/([A-Za-z0-9-]+)?$ news.php?url=$1 [L]

</IfModule>
Options+FollowSymLinks-多视图-索引
DirectoryIndex.php
重新启动发动机
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}\.php-f
重写规则^(.*)$$1.php
ErrorDocument 404 404error.php
重写规则^([A-Za-z0-9-]+)?$specification.php?url=$1[L]
重写规则^news/([A-Za-z0-9-]+)?$news.php?url=$1[L]

如何通过键入在index.php上重新定向?

我在htaccess中没有看到index.php

我想你的意思是:

RewriteRule ^(.*)$ index.php [L]
这意味着在此重写下的其他重定向将无法执行。命令事项;在需要时使用L标志

你的正则表达式:

RewriteRule ^([A-Za-z0-9-]+)?$ specification.php?url=$1 [L]
匹配所有内容(即使是空字符串;如您的示例所示)。如果你最后一个离开?出来另一个字符串不是可选的:

RewriteRule ^([A-Za-z0-9-]+)$ specification.php?url=$1 [L]

试试下面这样的规则

DirectoryIndex index.php

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

ErrorDocument 404 404error.php

RewriteRule ^([A-Za-z0-9-]+)?$ specification.php?url=$1 [L]

RewriteRule ^news/([A-Za-z0-9-]+)?$ news.php?url=$1 [L]

RewriteRule ^$ /themobilesapp/index.php [R=301,L]

它不起作用。当我输入时,它会打开此url,并显示错误*禁止您没有访问此服务器上/C:/wamp/www/theMobilesApp/index.php的权限*请在回答中尝试新规则。它正在索引页上重定向。主页上有许多页面链接,然后它也会在index.php上重定向它,然后删除
RewriteRule^(.*)$index.php[L]
行;只保留修改过的规格线,我没有添加任何东西。我只删除?从RewriteRule^([A-Za-z0-9-]+)$specification.php?url=$1[L],然后我的代码重定向index.php