URL Rewrite, handling unwanted url propagation
My website's navigation bar has the following url links
link1="project/one"
link2="project/two"
etc.
If I click on link1 then my RewriteRule will direct the page to show a url at domain.com/project/one which is good. Here is the rule:
RewriteRule ^project/([A-z0-9]+)$ project.php?p=$1
Now I am at domain.com/project/one, my navigation links are still the same as above, and when I click on link2 then my RewriteRule fires and logically it takes me to domain.com/project/project/two, but that is not what I want. What I want is domain.com/project/two.
I'm new to URL rewrites, can someone point me in the right direction about how to 开发者_JAVA百科handle this? Thanks all.
I was able to get relative links to work with my .htaccess rules by adding the base html tag with my siteroot set as the href in my page header. I have never heard of this tag before I ran into it searching for answers so I'm not sure how legit this is, but it does do what I want it to.
<base href="domain.com"/>
This not because of rewrite.
Your link is relative to the current url. To get what you need Make those links like
link1="/project/one"
link2="/project/two"
Your url rewrite internally shows the content from
project.php?p=one
and project.php?p=two
精彩评论