[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

.HTACCESS rewrite help needed

Posted on 2014-01-31
9
Medium Priority
?
246 Views
Last Modified: 2014-02-08
This is my .htaccess:

# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]
</IfModule>
# END YOURLS



I need to make sure that the www is stripped from what the user types in the url.  If the user includes www ie: http://www.domain.com/lent my php script does not work.  It only works if you use http://domain.com/lent

As you can see, the info after the / must be passed to yourls-loader.php

Thanks.
0
Comment
Question by:jasgot
[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
9 Comments
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39824169
Check out this article:
http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Apache/A_10732-The-Basics-of-htaccess-Files-and-URL-Redirection.html

The first example is about redirecting non-www traffic to www. You'd just need to invert the condition and action.
0
 

Author Comment

by:jasgot
ID: 39837433
I googled my problem and found an exact answer. Thank you.
0
 

Author Comment

by:jasgot
ID: 39841290
I've requested that this question be closed as follows:

Accepted answer: 0 points for jasgot's comment #a39837433

for the following reason:

Found the answer on my own.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39841291
Can you elaborate on why my suggestion didnt work for you? It was pretty much exactly what you were talking about..m
0
 

Author Comment

by:jasgot
ID: 39841689
I was unable to convert the info in that article to meet my needs. I found an exact drop in snippet elsewhere. For 500 points, I expected an answer not a research project.
0
 
LVL 35

Assisted Solution

by:gr8gonzo
gr8gonzo earned 2000 total points
ID: 39842077
That's unfortunate. If you can't convert the first code snippet in that article (non-www to www) into what you need by essentially removing a ! and tweaking the redirect, then an exact snippet isn't going to help you in the long run.

Articles that teach you this stuff are considered valid answers (not "research projects") by most people, since they are teaching you how to fish, not just feeding you for a day.

FWIW, the code snippet in that article to redirect non-www traffic to www is:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

The first step would be to invert the condition:
RewriteCond %{HTTP_HOST} !^www\.
to
RewriteCond %{HTTP_HOST} ^www\.

Then the second step would have just been to put in the non-www host, like this::
RewriteRule ^(.*)$ http://yourhost.com/$1 [R=301,L]

Again, the article would have explained how all that works.
0
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39842091
In any event, if you're going to close out the question by saying that you have a separate answer that is somehow vastly different than the above, please help future people who come across this question and share your answer and then accept it as the answer.
0
 

Accepted Solution

by:
jasgot earned 0 total points
ID: 39842456
# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.DOMAIN.org$ [NC]
RewriteRule ^(.*)$ http://DOMAIN.org/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]
</IfModule>
# END YOURLS

The article I found made it clear that these two lines had to be above the ReWriteCond lines that were already there.

RewriteCond %{HTTP_HOST} ^www.DOMAIN.org$ [NC]
RewriteRule ^(.*)$ http://DOMAIN.org/$1 [R=301,L]


I tried many variants using the article you provided as a guide and could not make it work until I found these instructions using google.

I'm sorry you were unable to provide an answer that worked for me. It was kind of you to provide the link to an article about ReWrite, though.

In the future, please remember that sometimes people come to EE for an answer because there is not enough time to figure it out on their own.  Since EE allows direct answers, you shouldn't be upset with people who are looking for direct answers.

Perhaps a better approach in the future might be "Here's an article about your topic, and here is a snippet that should work for you".

Cheers.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

650 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