简体   繁体   English

如何使用htaccess清理网址?

[英]How to clean a url with htaccess?

I have a problem with url when loading PHP scripts. 加载PHP脚本时,URL有问题。

The problem is that at the time of making the request to a php script, it loads normally, but when requesting another script, in the url they begin to gather and it looks like this: 问题是,在向php脚本发出请求时,它会正常加载,但是当请求另一个脚本时,它们会在url中开始收集,看起来像这样:

www.example.com/file.php/route1/file2.php www.example.com/file.php/route1/file2.php

I need this 我需要这个

www.example.com/file2.php www.example.com/file2.php

when i request another file, I need to have this 当我请求另一个文件时,我需要这个

www.example.com/file2.php www.example.com/file2.php

What I need is to hide everything that it after file1.php or file2.php to load the other scripts without problems. 我需要隐藏在file1.php或file2.php之后的所有内容,以加载其他脚本而不会出现问题。

Without seeing your HTML content and .htaccess file it is hard to determine the exact cause of your issue(s). 如果没有看到您的HTML内容和.htaccess文件,很难确定问题的确切原因。

Please verify the instructions in your .htaccess file. 请验证.htaccess文件中的说明。 If you are using a Rewrite rule you need to validate that it is correct, for example: RewriteRule ^/?$ "http\\:\\/\\/example\\.in" [R=301,L] If this rule is forcing a /route you obviously need to remove the /route from the instruction. 如果您使用的是重写规则,则需要验证它是否正确,例如: RewriteRule ^/?$ "http\\:\\/\\/example\\.in" [R=301,L]如果该规则强制执行/route您显然需要从指令中删除/route

Please make sure to reference in your <a> tags the appropriate path. 请确保在您的<a>标记中引用适当的路径。 If you are not formatting it properly you will end up with concatenation. 如果格式化不正确,将导致串联。 Are you using a framework? 您正在使用框架吗? If so this may have an impact on your URL formatting. 如果是这样,可能会影响您的URL格式。

Some example HTML a tags for you: <a href="http://example.com/file1.php">File 1</a> and <a href="/file1.php">File 1</a> will perform the same provided you do not have other factors impeding this simple approach. 一些为您准备的HTML a标签示例: <a href="http://example.com/file1.php">File 1</a><a href="/file1.php">File 1</a>如果您没有其他阻碍此简单方法的因素,则将执行相同的操作。

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

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