Solved

Help me get a really simple mod_rewrite to work?

Posted on 2013-11-04
5
332 Views
Last Modified: 2013-11-04
I am trying to create a Rewrite Rule in htaccess that will take a url such as
http://www.myplace.com/vwxyz

and rewrite it to

http://www.myplace.com/index.php/?cx=vwxyz

My server has recently been upgraded from Apache to LiteSpeed but according to the documentation it uses standard htaccess files (but without a performance hit)

The entire contents of the .htaccess file is as follows:

RewriteEngine on
RewriteRule ^c/([^/\.]+)/?$ index.php?cx=$1 [L]

and I've tried it both in the root and in the public_html directory.

What I get is

 404 Not Found
The resource requested could not be found on this server! Powered By LiteSpeed Web Server
LiteSpeed Technologies is not responsible for administration and contents of this web site!

Maybe I need a rewritecond but I don't know what that should be.  

For someone who knows this may be a laughably simple question - but I've spent way to much time trying to figure it out on my own.  A good answer is well worth the 500 points!
0
Comment
Question by:DMTrump
[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
  • 3
  • 2
5 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39622957
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?cx=$1 [L]
0
 

Author Comment

by:DMTrump
ID: 39623065
Bravo!  Works like a charm...

Now please explain what the two RewriteCond statements do so I'm a little smarter next time

I found that the trouble with most online documentation is it frequently shows stubs rather than complete examples!  Aaargh!
0
 

Author Closing Comment

by:DMTrump
ID: 39623069
Thanks a lot!  It's been years since I last messed with htaccess and I seemed to have forgotten everything I knew - which wasn't much!
0
 
LVL 58

Expert Comment

by:Gary
ID: 39623078
The two rewrites check the file or directory don't exist so the rewrite rule only fires if they don't
0
 

Author Comment

by:DMTrump
ID: 39623406
thanks!  I really appreciate your willingness to help an oldie having a newbee moment!

I'll study more of the htaccess documentation when I'm not in such a blinking hurry!
500 points well spent - okay, I have an unlimited account, so it didn't cost me anything extra - but still - thanks!
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

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 …
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
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 …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 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