Need to make .htaccess file show all pages html - .htaccess

I'm looking for .htaccess code that will make all my my pages .html code
example
http://domain.com/random
http://domain.com/random/blabla
http://domain.com/ all this pages here make them .html code

I don't understand your question. I'm assuming that all of your pages shown on that .htaccess document are written with HTML... are you saying that you want them to be shown as the raw HTMl on the .htaccess? That's not only impractical but it's also not possible as far as I know. Pleas word your questions more clearly.

Related

Keep people from opening pdf directly on my webiste

I am not sure if this is possible, but I figure I would ask.
I have hundred of PDF's stored on my website, and they are all getting indexed directly by Google, so people are doing a search and the engine is taking them directly to the PDF. The issue here is that the PDF's are related to language learning and have audios that go with them. If a visitor goes directly to the PDF, then they never see the audios.
I have another page I have designed which opens up the PDF in an Iframe, and shows the audios right next to them so the users can use it.
So my question is, is it possible to redirect a user who opens:
www.mywebsite.com/something.pdf
And have it redirect them to:
www.mywebsite.com/page-with-audios/
The key here is that the pdf should still open in the IFrame on my domain.
Thanks in advance for any assistance.
If you use routing, you could make a route which has the PDF name as parameter. The route could look something like this:
/{PDF_NAME}.pdf
This could be used to match all PDF's, like example.com/foo.pdf, example.com/bar-baz.pdf. Since you then have the name of the PDF they would like to view, you can redirect them to the /page-with-audio-files with some extra data like the name of the PDF. Then you can handle opening the iFrame.
EDIT
since I now see your question was directed at .htaccess, I think the following might work too.
add this rewrite to your .htaccess:
RewriteEngine On
RewriteRule ^([a-zA-Z\-]+.pdf)$ /page-with-audio/$1 [L, R=301]
This will make the $1 variable somepdf.pdf if your request url is http://example.com/somepdf.pdf.
Then it redirects the user to http://example.com/page-with-audio/somepdf.pdf so you know which pdf was requested.

links includes coma and hash htaccess

I'm using links like that:
find.php?id=1&n=2#loc
I want to my links look like:
but i dont know how to change htaccess and when/where use # to link some place in the page #loc
htaccess:
RewriteRule ^(.*),(.*),(.*)$ $3.php?id=$2&n=$1 [L,NC,NS,NE]
Help lease
The #loc part of the URL is never sent to the server, so there's no way for you to match against it in your htaccess file. Anything starting from the # in the URL is called a fragment and it's used by the browser, the server doesn't know it's even there.

.htaccess - fixing duplicate content issues

Some pages are showing up as duplicate content when I run a page crawl with seoMOZ.
for example:
/index.php
and
/index.php/
are being crawled as two separate pages. How I would implement a mod-rewrite to remove trailing slashes from only .php files?
Also
mysite.com/dir/
and
mysite.com/dir/index.php
are being flagged as duplicate content. I would prefer to have all "/dir/file.php" links redirected to "/dir/" for aesthetic reasons, but I'm not sure of how to do this or if it is the best thing to do from an SEO standpoint.
Thanks for help and advice.
An couple ideas:
Add a rel="canonical" link to the section of the non-canonical version of each HTML page.
Taken from http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394
This means that you can set only one page to be the "orginal" or "authoritative" page to be indexed instead of the pages that contain the same content. This is great for pages that show posts by tags, for example.
ALSO
You can do a redirect. Crack open you htaccess and redirect all inquiries with a query string.
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) $1?
There are a lot of ways to handle this, however.

Removing extensions with .htaccess on Drupal site

How do you use .htaccess to remove extensions. On the website, I want old links to work, but, site layout has changed. I want to map
/arithmetic/whole_numbers/practice/whole_number_rounding.html
to rediredt(mapped) to
/arithmetic/whole_numbers/practice/whole_number_rounding
I have moved from a standard html site to a Drupal site and the new page names have been defined to look like the original pages names, except the lack of .html extensions.
I know it doesn't answer your question directly but what about this:
http://drupal.org/project/path_redirect
Edited: if it's not enough try this:
drupal.org/documentation/modules/path

mod_rewrite for name fields

I am complete newbie in mod_rewrite, and I have been going through some sites reading how to handle this, all I could find was when the get variable was numbers and nothing about strings, and it turns out be over my head.
What I want to do is to rewrite display.php?name=blahblah123 to display/blahblah123
Together with the answer, I would love some sites where I can build some grasp over mod_rewrite myself.
Thanks
Edit:
With more searching, I came up with this
RewriteEngine On
RewriteBase /
RewriteRule ^display/([a-z]+)$ display.php?name=$1 [L]
The code above works, but for some reason, The page I get has no CSS. The CSS I see included shows Hostgator's 404 page CSS. But HTML looks fine, so does the content and everything else. Any idea?
Just to be clear, mod_rewrite is something that happens internally in apache. I find that sometimes people do not understand what it does and doesn't do. It will not take a url that you output and change it from
display.php?name=blahblah123
to
display/blahblah123
It will however, allow someone to make a request from your site for display/blahblah123 and convert that to display.php?name=blahblah123, so that your display.php script can operate on it.
Rewrite rules require an understanding of regular expressions. The better you understand regex the easier mod_rewrite will be for you.
As a beginner this article should help: http://www.sitepoint.com/guide-url-rewriting/
For your specific question, I'd probably use:
RewriteRule ^display/([a-zA-Z0-9]+)$ /display.php?name=$1
Try to put a "/" in front of the css file name.
<link rel=".." href="/style.css".
instead of
<link rel=".." href="style.css".

Resources