I have a menu, which when you open goes to /#0 to indicate that the menu has been opened and the menu the slides in and shows. What I want to know is how to rewrite the url so that instead of site.com/#0 we simply get site.com. I believe this can be done with .htaccess though I'm not quite sure how. Thanks in advance.
Please try this if I'm getting your point.
# Rewrite --- www.site.com/#0 => www.site.com
RewriteRule ^$ /?&%{QUERY_STRING}
Related
This is normal question, but i am very weak regarding .htaccess
I have one website in html.All Pages are in .html. Now only enquiry page is enquiry.php
So I want enquiry page from enquiry.php to enquiry.html in URL.
It should not affect other html files
Pls help
Provided you've already turned "RewriteEngine On" your rule might looks something like this:
RewriteRule ^enquiry.html$ /enquiry.php [QSA,L]
However depending upon your web host, that may not work out of the gate. For example, you might need to add a slash before the .html so it would read:
RewriteRule ^enquiry\.html$ /enquiry.php [QSA,L]
I've also seen where you may need to add "Options FollowSymLinks" to the top of the .htaccess file.
I have a page with a RewriteRule like this:
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/$ index.php?user=$1&language=$2 [QSA,L]
In the index.php page, I have several links pointing to hashes # of element ids. When the user lands on the page, he gets this nice looking url:
mydomain.com/username/en
Which points to
mydomain.com/index.php?user=username&language=en
The problem is, as soon as one of the links is clicked, the browser changes the url to
mydomain.com/#id
Isn't it supposed to change to something like this?
mydomain.com/username/en#id
I want my url to look like the one above, that seems to be the expected behavior of the page...
Any thoughts on this?
Nevermind... just found the problem
I was using JS to push history states and it ended up messing with the urls!
I have image.html and I want It to be shown in browser as image.jpg, because there are some operations when showing picture, that can't be done before or after. Is it even possible with .htaccess and url rewriting?
I tried
RewriteEngine On
RewriteBase /
RewriteRule ^image\.html$ image.jpg
but without any luck.
Thanks for all answers
First of all, you'll need let's say a PHP script. Call it image.php. After that, use a GET parameter to handle the image name. Let's call it name. To call a picture you need image.php?name=allo.
Now. In the PHP script, you need to specify in the header it's an image, JPEG. Required. After that, just "print" the picture within the page.
All you need after is Rewrite rule.
RewriteEngine On
RewriteBase /
RewriteRule ^image\.php?name=(.*)$ /images_jpeg/$1
The header is really important. This is why it doesn't work with an HTML file.
I want to create a single page such as this:
http://www.mywebsite.com/special/index.html
But anything in the /special/ folder should be able to load the index.html page. For example, if you go to
http://www.mywebsite.com/special/another-page.html
It should still load the index page but not change the URL in the browser or to search engines. Basically, you should be able to go to any page in the /special/ folder, keep the URL the same as you enter, but always load the index.html page. Any ideas?
A 404 or 301 redirect wouldn't work because that changes the URL in the browser and to search engines...
Thanks in advance!
A 404 redirect would not help, but a custom 404 handler would:
error404.php:
<?php
include('path/to/special/index.html');
?>
Assuming .html is a static or PHP page. If it is something else, youse the equivalent construct of that environment.
Using apache mapping it should be possible. I don't how to exactly do that but this doc http://httpd.apache.org/docs/2.0/urlmapping.html probably has the answer.
It is possible to use patterns to map URL to filesystem locations.
I think (untested) something like this would work in an .htaccess file in the special directory if you have the ability to use rewrite rules:
RewriteRule ^.*$ index.html
You would have to symlink index.html in the special directory to the real index.html.
The ^.*$ just means (beginning of line)(any amount of anything)(end of line) - basically a wildcard; there might be a better way of writing it.
I have links to cold fusion extension pages, such as:
/hsl/incs/10/header.cfm
that simply need to be:
/hsl/incs/10/header.html
I only want the internal links changed, so that if there is a link like this:
http://somesite.com/usescoldfusiontoo.cfm
I dont want that changed. So, I thought of doing reg ex, but find through research that might not be the best way...any help would be appreciated!
Try this in your .htaccess file:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteRule ^(hsl/.*)\.cfm$ /$1.html [NC,L,R=301]
This is assuming you are internally redirecting every /hsl/*.cfm to /hsl/*.html