在.htaccess中添加规则后,我的链接无效 [英] My link isn't working after adding rules in .htaccess

查看:89
本文介绍了在.htaccess中添加规则后,我的链接无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我的索引页面中有一个id为chart的div,所以如果我将index#charts作为锚点中的值标记它的工作正常,但现在我已经在我的项目中为漂亮的网址添加了.htaccess。



每隔一页工作正常,我在htaccess中写了规则如果网址是all-charts / chart-name / year,则重定向到index#charts。我的问题是现在它的开放索引页面,但没有向下滚动到那个div。



如果我在url中直接键入index#charts它的工作。



我知道我做错了什么吗?



这是一种复杂的结构,因为我有一个URL类,它检查所有请求并返回适当的页面。例如,如果我想返回名为blog.php的页面,那么在链接中我将使用?page = blog或页面user_forum.php我将给出href属性值?page = user_forum 。但现在我正在尝试将其更改为seo友好网址。



这是我的htaccess代码



RewriteEngine On



RewriteRule ^(后端)$ / backend /?page = index [NC,L]

RewriteRule ^(后端)/ ?page =([a-zA-Z0-9 -_] +)$ / backend /?page = $ 1 [NC,L]



RewriteRule ^(博客)/([a-zA-Z0-9 -_] +)$ /?page = read_blog& slug = $ 2 [NC,L]



RewriteRule ^(所有图表)/([a-zA-Z -_] +)/([0-9])$ /?page = index#charts [NC,L]



RewriteRule ^([a-zA-Z0-9 -_] +)/([0-9] +)$ /?page = $ 1& cp = $ 2 [NC, L]

RewriteRule ^([a-zA-Z0-9 -_] +)$ /?page = $ 1 [NC,L]





在锚标签中我使用了这样的东西

< a href =all-charts / january-chart / 2018> 1月2018年< / a>



谢谢,

Anchal Bhargava



我的尝试:



我是检查htaccess规则和锚标记中的所有拼写。我试过改变身份证。我添加了一个页脚消息,因此下面有一个内容

解决方案

/ backend /?page = index [NC,L]

RewriteRule ^(后端)/?页=([A-ZA-Z0-9 -_] +)

/后端/?页=

1 [NC,L]



RewriteRule ^(博客)/([a-zA-Z0-9 -_] +)


Hello,

I have a div in my index page whose id is "charts", so if I give "index#charts" as a value in anchor tag its works fine but now I have added .htaccess in my project for pretty urls.

Every other page is working fine, and I have write a rule in my htaccess that, if the url is "all-charts/chart-name/year" then redirect to "index#charts". My problem is that now its opening index page but not scrolling down to that div.

If I directly type "index#charts" in url its working.

Any idea what I am doing wrong?

Its kind of a complex structure, as I have a URL class which check all the request and returns the appropriate page. For example if I want to return the page named "blog.php" then in the link I will use "?page=blog" or for page "user_forum.php" i will give the href attribute value of "?page=user_forum". But now I am trying to change it to seo friendly url.

This is my htaccess code

RewriteEngine On

RewriteRule ^(backend)$ /backend/?page=index [NC,L]
RewriteRule ^(backend)/?page=([a-zA-Z0-9-_]+)$ /backend/?page=$1 [NC,L]

RewriteRule ^(blog)/([a-zA-Z0-9-_]+)$ /?page=read_blog&slug=$2 [NC,L]

RewriteRule ^(all-charts)/([a-zA-Z-_]+)/([0-9])$ /?page=index#charts [NC,L]

RewriteRule ^([a-zA-Z0-9-_]+)/([0-9]+)$ /?page=$1&cp=$2 [NC,L]
RewriteRule ^([a-zA-Z0-9-_]+)$ /?page=$1 [NC,L]


And in anchor tag i used something like this
<a href ="all-charts/january-chart/2018">January 2018</a>

Thanks,
Anchal Bhargava

What I have tried:

I double check all the spelling in htaccess rule and in anchor tag. I tried changing the id. I added a footer message so there is a content beneath it

解决方案

/backend/?page=index [NC,L]
RewriteRule ^(backend)/?page=([a-zA-Z0-9-_]+)


/backend/?page=


1 [NC,L]

RewriteRule ^(blog)/([a-zA-Z0-9-_]+)


这篇关于在.htaccess中添加规则后,我的链接无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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