...

View Full Version : mod_rewrite and .htaccess



Taipan
04-25-2008, 06:34 AM
I have found loads of links and sample codes on this topic, but nothing to do what I want. I just want to show my base domain name regardless of what page is being looked at. I have a .htaccess file with this in it:-

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*/*.html
RewriteRule ^(.*)*.html$ http://www.mydomain.net/$1 [R=301,L]
This just chops the .html of the file name. Can anyone help me hide the whole file name and just show the domain name?

Pennimus
04-25-2008, 11:04 AM
Purely out of curiosity, why do you want to do this?

Taipan
04-25-2008, 11:32 AM
Purely out of curiosity, why do you want to do this?
Eventually I am going to use dynamic pages with variables passed to the server in the url. I want to hide them. I like the idea of just showing the domain name in the url.

shyam
04-25-2008, 12:45 PM
This just chops the .html of the file name. Can anyone help me hide the whole file name and just show the domain name?

how will ur webserver figure out which page to serve next then?

tis sad that someone still wants to show only their domain name in the addressbar...anyway the only way to do it is to use frames/iframes or use flash

gnomeontherun
04-25-2008, 02:42 PM
I think you could also use Domain Masking, which would make your domain mask the actual location of your pages with just the simple domain name the entire visit.

abduraooft
04-25-2008, 02:47 PM
I think you could also use Domain Masking, which would make your domain mask the actual location of your pages with just the simple domain name the entire visit.
How can we effectively do that?

gnomeontherun
04-25-2008, 02:54 PM
Obviously the page can still be found if one knows the correct address, but it was an idea. I think it would do what the OP wanted for the most part. One would have to set it up with a domain registrar to do it. Not really recommended, but thought I'd throw it out there. If its a bad idea to do, I'd love to know that since I've never heard any the +/- of it.

Pennimus
04-25-2008, 03:44 PM
It's a terrible idea, really. Sit and think about the implications of only having one URL for a second:


Impossible to bookmark, link to or otherwise refer to any page other than the homepage.
Impossible for search engines to index anything other than your homepage.
Impossible for users to use the URL as a cue to where they are in the site.


Ways to do it:


Contain all content hidden in layers on one page, and use JavaScript to swap which layer is visible.
Use AJAX to dynamically swap content on the page.
Use frames.
Use flash.


Taipan - if you think variables are ugly the answer is not to try and hide them! Either change them so they aren't ugly, or use mod_rewrite to change them into a conventional domain/directory/file structure.

gnomeontherun
04-25-2008, 04:14 PM
It's a terrible idea, really. Sit and think about the implications of only having one URL for a second:


Impossible to bookmark, link to or otherwise refer to any page other than the homepage.
Impossible for search engines to index anything other than your homepage.
Impossible for users to use the URL as a cue to where they are in the site.


Ways to do it:


Contain all content hidden in layers on one page, and use JavaScript to swap which layer is visible.
Use AJAX to dynamically swap content on the page.
Use frames.
Use flash.




This is just a question, but don't your suggestions have some of the issues as masking the domain?

Obviously with masking, bookmarks are restricted only to the homepage, but with Flash, Frames, Ajax, hidden layers, these are all restricted to bookmarking the page in which they are placed, not necessarily allowing for easy cueing. A good design would minimize that, but its still an issue.
Search engines still index the site, and in fact they index it with the correct URL. The mask isn't detected. Its because a mask doesn't replace the actual URL. So if my homepage links to mydomain.com/page2.html that is still the link when it is indexed by a search engine. In which case the domain mask is lost when indexed. You could get around this by checking the URL for the mydomain.com and redirect to mymask.com, but this is all silly. Masking is merely a forwarding address which persists during the visit. Unless a visitor enters from that address, the mask is not applied.

I agree that I would rather use any of your items, but they don't solve all of the issues present either. I guess I don't know if there is a solution exactly to this question.

Taipan
04-26-2008, 01:51 AM
how will ur webserver figure out which page to serve next then?

tis sad that someone still wants to show only their domain name in the addressbar...anyway the only way to do it is to use frames/iframes or use flash
I am not really sure how the mod_rewrite works. The code I posted still serves the correct webpage, but doesn't display the .html part. I just wanted to know a way to not display the page name either.

I don't understand why you would think this is sad, and why 'still'. If other people have wanted to do it then they have a reason too. I have been to a site recently that only shows the domain name regardless of which page I looked at. I want to do the same with my site. I am not trying to do anything malicious.

Taipan
04-26-2008, 02:00 AM
It is no real big deal if I can't, but the bookmarking, indexing etc, really doesn't matter to me. The site is a very simple site and is going to have 4 pages. It is not designed to be an overly public site, it is going to document a project I am doing and I will probably only link people to it that express interest.

I'll probably just use Pennimus suggestion and "use mod_rewrite to change them into a conventional domain/directory/file structure."

Pennimus
04-27-2008, 03:44 PM
This is just a question, but don't your suggestions have some of the issues as masking the domain?

Yes they all do. I wasn't suggesting they didn't :thumbsup: However I wanted to list some more options for the OP in case he wanted to go ahead with it (which I'm happy to see he isn't going to).

Angie1313
04-28-2008, 07:12 PM
I would also think you run the risk of getting the search engines perturbed with you. I could see them possibly accusing you of cloaking. May not be worth it



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum