Could you help me with this htaccess problem of mine?
My URL is:
mysite.com/blog.php?post=01/01/2012/my-first-post
And I want to transform it into this:
mysite.com/post/01/01/2012/my-first-post/
Which I partially solve this by using this:
RewriteRule ^post/([A-Za-z0-9-]+)/?$ blog.php?postd=$1 [NC,L]
Now here comes the problem. When I try to click the second post "01/01/2012/my-second-post" which was suppose to go to
mysite.com/post/01/01/2012/my-second-post
but in return it goes to
mysite.com/post/01/01/2012/my-first-post/01/01/2012/my-second-post
Try adding in the header of all your pages:
<base href="/">
Related
Htaccess is not my favourite and please be kind enough to help me with this.
Ex. Www.domain.com/about.php shows the site with styles rightly. In the browser if add www.domain.com/about.php/ or www.domain.com/about.php\ all the styles are ruined and page is distorted.
How to eradicate backslash and slash after file extension in htaccess.
Appreciate your help
Rgds
It is path/to/style.css but when you add / after about.php , the included file path will be changed to about.php/path/to/style.css so nothing will show up.
To solve this issue add this <base href="/"> between <head> Tags in order to keep a base fixed :
<head>
<base href="/">
</head>
Update:
As per your comment that you want to add rules in .htaccess for this case , try this :
RewriteEngine On
RewriteRule ^(.+)\.php/(.*)(\.css)$ $2$3 [L]
I want to be able to Rewrite a following url:
www.mysite.com/en/contact
to something like this
www.mysite.com?l=en&p=contact
but keep the structure.
I tried the following RewriteRule:
RewriteEngine On
RewriteRule ^([\w-]+)/([\w-]+)/?$ index.php?l=$1&p=$2 [L]
but the browser then wants to load all the included scripts like the css from
www.mysite.com/en
How can I tell the browser, that it shouldn't follow the url link?
Or something like that
Thank you for your help
Chris
There are 2 methods to solve this:
1) Use base tag inside head tag
<base href='/'>
2)Use relative links
<link rel='stylesheet' href='/css/style.css'>
Here the browser looks for the CSS file in the folder in the root named CSS, whatever the URL request may be.
I need help from experts to solve my problem. I'm just starting to learn rewriterule, rbase, and rcond. I want to rewrite my site link like codeigniter MVC. For example:
http://localhost/app/index.php?page=profile&user=john -> http://localhost/app/index/page/profile/user/john
How to do that? I tried to change for many times, but i don't get url like that but error occured.
RewriteRule ^index/page/(.*)/user/(.*)$ /index.php?page=$1&user=$2 [L]
In my .htaccess folder I'm using RewriteRule to forward music.php?artist=name to music/name. My problem is, if you click another link, instead of going to site.com/music/otherartist, it goes to site.com/music/name/otherartist (you're still stuck in the "music/name" directory). I've tried adding
RewriteBase /
and I get the error "Object not found." I'm sure the solution to this is really simple, but I haven't figured it out yet. :/
You need to change your links to be absolute URLs or add a relative URI base to the header of your pages:
<base href="/" />
i am using the rewrite rules in htaccess but i am getting error on site,
while adding a / (slash) into the link
My Example Code:
RewriteEngine On
RewriteRule ^categories/(.*)$ ?act=directory&category=$1 [L]
actually i want to call this link from the category listing where the href link is
categories/category-name
now if i call this link like this
categories-category-name
then it works fine, but if i add the slash then the site looks as it doesnt have the css :(
only unstyled text i can see.
Thanks In Advance
Please Advise.
You need to add a slash in your css path
href="/css/your_style_name.css"
This will work