问题使用URL重写(相对路径不工作) [英] Problem using URL rewrite (Relative Paths not working)

查看:378
本文介绍了问题使用URL重写(相对路径不工作)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用顺序.htccess文件,重写我的网址。我使用下面的规则在我的.htaccess文件

I am using a .htccess file in order to rewrite my URLs. I am using the following rules in my .htaccess files

Options +FollowSymlinks
RewriteEngine on 
RewriteBase /
RewriteRule ^product/([0-9]+)/([A-Za-z0-9+]+)$ /product.php?productid=$1&prodname=$2

重写工作的罚款。

The rewrite worked fine.

但是,当我试图通过这是在所有的情况下,相对路径来访问其他网页,网址是没有得到重定向正确。

But when i try to access any other page through relative path which is in all the cases, the URL is not getting redirected properly.

就像在下面的例子

<form action "something.php" method="post">
   <input type="text" name="1" />
   <input type="submit" value="submit" />
</form>

当我点击提交,即获取加载的页面的http://mydomain/product/1/something/something.php 不存在,因而引发一个404错误

When I click on submit, the page that gets loaded is http://mydomain/product/1/something/something.php which does not exist and hence throws a 404 error

我试图用头底座的标签,但是,当我使用页面的锚和模态窗口这造成的问题。它被重定向到索引页面。

I tried using the base tag in the head but this creates problem while I am using page anchors and modal windows. It gets redirected to the index page.

请让我知道如果进一步的细节是必需的。

Please let me know if further details are required.

我是相当新了这一点。因此,能不能有人请帮助我?

I am fairly new to this. So, could someone please help me with this?

在此先感谢, 卡尔蒂克

Thanks in Advance, Kartik

推荐答案

这是一个URL解决问题。请参阅<一href="http://stackoverflow.com/questions/891775/modrewrite-url-info-required/891785#891785">http://stackoverflow.com/questions/891775/modrewrite-url-info-required/891785#891785了解详细信息。

This is a URL resolving issue. See http://stackoverflow.com/questions/891775/modrewrite-url-info-required/891785#891785 for details.

您既可以使用绝对URL路径或绝对URL:

You can either use absolute URL paths or absolute URLs:

<form action="/something.php" method="post">
<form action="http://example.com/something.php" method="post">

或者更改基本URL(见 BASE HTML元素),使每一个相对URL是从URL解析,而不是当前的URL:

Or you change the base URL (see BASE HTML element) so that every relative URL is resolved from that URL and not the current URL:

<base href="/">
<base href="http://example.com/">

这篇关于问题使用URL重写(相对路径不工作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆