Solved

mod rewrite issue

Posted on 2013-06-02
8
278 Views
Last Modified: 2013-06-02
Hey guys, got a bit of a basic issue that I cant quite work out. Is pretty simple but I'm messing something up.

running ubuntu using .htaccess to perorm a rewrite on my webserver.

basicaly, I have 2 urls
mishmash.com
mishmash.com.au

I want them to both to go mishmash.com/blog/
The current rule I have works (below) however, I have just tried going to www.mishmash.com and the rewrite rule does not work. It goes to the root directory on my server (which is not the /blog/).

I've tried to add something to my rule, but it spits out something like this
mishmash.com/blog/blog/blog/blog/blog/blog and so on and so forth.

Any assitance would be great.
Cheers



Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mishmash.com.au$
RewriteRule ^$ http://mishmash.com/blog [L,R=301]

RewriteCond %{HTTP_HOST} ^mishmash.com$
RewriteRule ^$ http://mishmash.com/blog [L,R=301]
0
Comment
Question by:samabdelhamid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 1

Expert Comment

by:ForFracksSake
ID: 39214384
Hey there,

I'm assuming you are currently using a version cPanel. There are several ways of doing this if this is the case:

1) Domain redirect in your Domain section of the cPanel. Very simple

2) In your public_html folder (also called the “root html” folder), you need to create a file called .htaccess. From this file we are going to use a few lines to redirect those requests in a search engine friendly way.

Add the following lines to that file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?YourDomain.com$
RewriteRule ^(/)?$ blog [L]

The only change you need to make is to change “YourDomain.com” to your domain. This will then redirect everything from the domain to the folder /blog at that domain. If you want to change that folder just edit the “blog” part
0
 

Author Comment

by:samabdelhamid
ID: 39214397
Thanks for the reply!

I ended up doing this (with.htaccess file)


RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?mishmash.com$
RewriteRule ^(/)?$ blog [L]

RewriteCond %{HTTP_HOST} ^(www.)?mishmash.com.au$
RewriteRule ^(/)?$ blog [L]

which seems to be working. I didnt know how else to make one rule for both .com and .com.au domains....im sure its easy with regex, but I struggle with regex, so 2 rules seems to work..
0
 
LVL 1

Accepted Solution

by:
ForFracksSake earned 500 total points
ID: 39214402
Or.. this may be your best bet

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) http://www.example.com/store [R=301,L]



Remember, not everyone types the http:// , and www. is technically a subdomain. So you have to have that wildcard element in there as above shows. Let me know if this works bud.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 1

Expert Comment

by:ForFracksSake
ID: 39214408
One more thing. This article you may find handy as well. I pulled it from the Hostgator.com support portal (they have the best articles and KB's), and I find this useful and I work for another Hosting Company now.. that tells you something.

http://support.hostgator.com/articles/specialized-help/technical/apache-htaccess/apache-mod_rewrite-and-examples
0
 

Author Comment

by:samabdelhamid
ID: 39214419
That one works perfect!
Brilliant thank you!

I know there was a way to do it in 2 lines, I just couldn't figure it out.

I was originally happy with the first rule I had, but then someone told me that www. doesn't work (they were typing www in, I never do so I never guessed to test it..)

So if i understand correctly, your condition, takes Anything that's typed in, and replaces it with the rewrite rule. ?

Cheers
0
 

Author Closing Comment

by:samabdelhamid
ID: 39214422
Excellent answer. Excellent help.
0
 
LVL 1

Expert Comment

by:ForFracksSake
ID: 39214457
Basically, there's different ways for different situations. I was also thinking about the two line rule, but sometimes a particular way will work and others won't. .htaccess is a crazy thing sometimes. Good luck buddy!
0
 

Author Comment

by:samabdelhamid
ID: 39214550
Cheers! really appreciate the help :)
0

Featured Post

Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question