简体   繁体   English

如何使用.htaccess url.tld / file.php重定向到url.tld / file.php /

[英]how to redirect with .htaccess url.tld/file.php to url.tld/file.php/

I know that this is a stange question but i do not know the reason why my page is not loading the ".php" file when i access it with hxxp://url[dot]tld/file.php . 我知道这是一个严肃的问题,但是当我使用hxxp:// url [dot] tld / file.php访问它时,我的页面没有加载“ .php”文件的原因我不知道。 To see the content i have to access it via hxxp://url[dot]tld/file.php/ . 要查看内容,我必须通过hxxp:// url [dot] tld / file.php /访问它。 i know that i can do this from cpanel (redirects - section) but my provider has a customed panel and i found nowhere redirects option. 我知道我可以从cpanel(重定向-部分)执行此操作,但是我的提供者有一个自定义面板,但我找不到无处重定向选项。 I tried some codes from internet to redirect the old url to the new one via .htaccess but im redirected to hxxp://url[dot]tld/file.php///////////////// or something like that. 我尝试了一些来自Internet的代码,以通过.htaccess将旧网址重定向到新网址,但我将其重定向到hxxp:// url [dot] tld / file.php /////////////// // 或类似的东西。

edit: .htaccess content now 编辑:.htaccess内容现在

RewriteEngine on
RewriteCond %{HTTP_HOST} ^online\.my\-domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.online\.my\-domain\.com$
RewriteRule ^/?$ "http\:\/\/google\.com\/" [R=302,L]
//Rewrite to www
Options +FollowSymLinks

RewriteCond %{HTTP_HOST} ^online.my-domain.com[nc]
RewriteRule ^(.*)$ http://www.online.my-domain.com/$1 [r=301,nc]


Redirect 301 /php-file-with-problems.php /php-file-with-problems.php/

How i said im redirected to online.my-domain.com/php-file-with-problems.php////////////// 我怎么说我即时通讯重定向到online.my-domain.com/php-file-with-problems.php///////////////

Multiple slashes are being added to the filename by The redirect directive, and you are getting a redirect loop, to resolve this you will need to use RedirectMatch redirect指令将多个斜杠添加到文件名中,您将获得一个重定向循环,要解决此问题,您将需要使用RedirectMatch

RedirectMatch 302 /phpfile$ /phpfile/

Clear your browser cache before testing this. 在测试之前,请清除浏览器缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM