Reputation: 1346
I have some questions about htaccess
,
but first of all I want to apologize for my bad English.
I want to ask about RewriteRule
.
1.If I want to to change my url extension , for example if I want my url to be mysite.com/file.html
but the real url is mysite.com/file.php
, how to do that ?
I used this code
RewriteRule ^(.*)\.html$ $1.php [R=301,L]
but when I tried it, I found that .html
url redirect to .php
2.when I try to rewrite url from http://mysite.com/file.php?varOne=something&varTwo=somethingelse
to http://mysite.com/file/something/somethingelse/
all css,js and images don't appear bcz the dir changed ,
How can I prevent that ?
Thanks
Upvotes: 1
Views: 1387
Reputation: 785316
Add the line:
RewriteCond %{REQUEST_FILENAME} !-f
before all of your RewriteRule lines to prevent redirection for css, js and images.
Upvotes: 0
Reputation: 3495
Have you tried using [L]
instead of [R=301,L]
?
RewriteRule ^(.*)\.html$ $1.php [L]
And when embedding CSS or images in your html, try to begin with a slash to get the files from the root directory:
<link rel="stylesheet" href="/css/style.css" />
The same with images:
<img src="/images/pic.png" alt="image" />
<img src="/mypic.png" alt="image" />
Upvotes: 2